Page 1 of 1
Date and Time Format changing by macros
Posted: Wed Dec 12, 2012 6:16 pm
by HossamAli
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
Re: Date and Time Format changing by macros
Posted: Wed Dec 12, 2012 9:29 pm
by GasMan
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
Re: Date and Time Format changing by macros
Posted: Thu Dec 13, 2012 4:51 pm
by HossamAli
Thanks for your quick response, I will test and back to you if I need more help
Thanks again
Re: Date and Time Format changing by macros
Posted: Thu Dec 13, 2012 5:55 pm
by HossamAli
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
Re: Date and Time Format changing by macros
Posted: Fri Dec 14, 2012 2:00 pm
by GasMan
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
Re: Date and Time Format changing by macros
Posted: Sun Dec 16, 2012 9:05 am
by HossamAli
thank you very much