Advertisement

Date and Time Format changing by macros

Discussions about chromatography data systems, LIMS, controllers, computer issues and related topics.

6 posts Page 1 of 1
Dears
I have a macro that create text file including the sample info and some other parameters.
Also it is include the Date and time of injection.

Ny problem that the date and time format not as I need although I confirm that window system for the time and date as I need. If any way to make the macro write the date and time by the format I need like this
yyMMdd

M/dd/yyyy h:mm:ss AM/PM

Thanks in advance
Here is the decription of the command Date$ for GC ChemStation.

***************************************************************************

Date$


Returns today's date in mm/dd/yy format.

Group

Timing functions

Syntax

Date$ ([Mode], [TimeValue], [FormatString])

Parameters Type/Description

Mode Defines the format of the date string.

0 Default returns the ANSI C date string. For example, mm/dd/yy.
1 Returns the date format as defined in the international settings of the Windows control panel.
2 Accepts the parameter FormatString to specify the date format.

TimeValue A value that defines the time as the number of seconds since 1.1.1970. The default is the current time.
FormatString Specifies the format of the date string similarly to sLongDate in the [intl] section of win.ini.

d day (1 - 31)
dd day (01 - 31)
ddd day (Mon - Sun)
dddd day (Monday - Sunday)
M month (1 - 12)
MM month (01 - 12)
MMM month (Jan - Dec)
MMMM month (January - December)
yy year (00 - 99)
yyyy year (1900 - 2040)
e.g. "dddd, d.MMM.yyyy" outputs "Monday, 4.Mar.1993"

Discussion

Function returns today's date in the specified format.

Return Value

String

*************************************************************************

If the Windows system gives you the format that you need, it looks as though setting the Date$ mode to '1', would use the windows format. The default value for Date$ does NOT use the windows format.

Gasman
Thanks for your quick response, I will test and back to you if I need more help
Thanks again
Dear Sir
I try to follow your instruction but failed. Could you help me in modfy my macro to get what I want:

My Macro is

Name C
Local PREPDATE$,INJD1$,INST1$,DESC1$,COMMENT1$
PREPDATE$="#"
TEMP$=ObjHdrText$(chromres[1],"sampleinfo")+" "
IF INSTR(TEMP$,"PREPDATE=")>0 THEN
PREPDATE$=TEMP$[INSTR(UPPERCASE$(TEMP$),"PREPDATE="):LEN(TEMP$)]
IF LEN(PREPDATE$)>9 THEN
PREPDATE$=PREPDATE$[10:LEN(PREPDATE$)]
ENDIF
IF INSTR(PREPDATE$,chr$(13))=1 THEN
PREPDATE$="#"
ENDIF
IF INSTR(PREPDATE$,chr$(13))>1 THEN
PREPDATE$=PREPDATE$[1:INSTR(PREPDATE$,chr$(13))-1]
ENDIF
PREPDATE$=ConvertText$(Trim,PREPDATE$)
IF LEN(PREPDATE$)=0 THEN
PREPDATE$="#"
ENDIF
EndIf

IF LEN(PREPDATE$)>9 THEN
PREPDATE$=PREPDATE$([2], [0], ["MM/dd/yyyy"])
EndIf

INJD1$=OBJHDRTEXT$(CHROMRES[1],"INJDATETIME")
WHILE INSTR(INJD1$,",") > 0
INJD1$=INJD1$[1:INSTR(INJD1$,",")-1]+INJD1$[INSTR(INJD1$,",")+1:LEN(INJD1$)]
ENDWHILE
WHILE INSTR(INJD1$," ") > 0
INJD1$=INJD1$[1:INSTR(INJD1$," ")]+INJD1$[INSTR(INJD1$,",")+2:LEN(INJD1$)]
ENDWHILE


print "PREPDATE"+CHR$(9)+PREPDATE$,"INJDATETIME"+CHR$(9)+INJD1$
endmacro
PREPDATE should be 120103

INJDATETIME should be 1/4/2012 5:47:34 AM

Thanks in advance
I see that you are setting Temp$ to the contents of the header item 'Sampleinfo'. My understanding is that the information in this header is data that has been entered by the user, so the format of the date depends on how the user has entered it. If you are using a macro to enter the data into the 'Sampleinfo' header, then you should look at that macro.

Otherwise, the only way that I see is to take the string apart and rearrange it to the format that you need.

Gasman
thank you very much
6 posts Page 1 of 1

Who is online

In total there are 2 users online :: 1 registered, 0 hidden and 1 guest (based on users active over the past 5 minutes)
Most users ever online was 4374 on Fri Oct 03, 2025 12:41 am

Users browsing this forum: Ahrefs [Bot] and 1 guest

Latest Blog Posts from Separation Science

Separation Science offers free learning from the experts covering methods, applications, webinars, eSeminars, videos, tutorials for users of liquid chromatography, gas chromatography, mass spectrometry, sample preparation and related analytical techniques.

Subscribe to our eNewsletter with daily, weekly or monthly updates: Food & Beverage, Environmental, (Bio)Pharmaceutical, Bioclinical, Liquid Chromatography, Gas Chromatography and Mass Spectrometry.

Liquid Chromatography

Gas Chromatography

Mass Spectrometry