craigorama
Technical User
Hi everyone!
I'm create and update new date and time fields from an existing date and time fields. Basically converting from one time zone to another.
I've tried to set up the new fields as ShortDate and ShortTime but when i update the fields both time and date display in each. I just want to display the time in the NEW_TIME field and date in the NEW_DATE field.
Here is my code:
'======================================
'create the NEW_TIME field
'======================================
strSQL = "ALTER TABLE " & tabName & " ADD NEW_TIME Date ShortTime"
DoCmd.RunSQL strSQL
MsgBox ("NEW_TIME field added to the table")
'======================================
'create the NEW_DATE field
'======================================
strSQL = "ALTER TABLE " & tabName & " ADD NEW_DATE Date ShortDate"
DoCmd.RunSQL strSQL
MsgBox ("NEW_DATE field added to the table")
'======================================
'change uploadtime from gmt to mst
'by subtracting 7 hrs
'======================================
strSQL = "UPDATE [TELLUS_TEMP_UPLOAD] " & _
"SET [TELLUS_TEMP_UPLOAD].NEW_TIME = ([UPLOAD_DATE]+[TELLUS_TEMP_UPLOAD]!UPLOAD_TIME)-CDate(#12/30/1899 7:0:0#)"
DoCmd.RunSQL strSQL
MsgBox ("Time Changed")
'======================================
'change date from gmt to mst
'by subtracting 7 hrs
'======================================
strSQL = "UPDATE [TELLUS_TEMP_UPLOAD] " & _
"SET [TELLUS_TEMP_UPLOAD].NEW_DATE = ([UPLOAD_DATE]+[TELLUS_TEMP_UPLOAD]!UPLOAD_TIME)-CDate(#12/30/1899 7:0:0#)"
DoCmd.RunSQL strSQL
MsgBox ("Date Changed")
thanks for your help!
I'm create and update new date and time fields from an existing date and time fields. Basically converting from one time zone to another.
I've tried to set up the new fields as ShortDate and ShortTime but when i update the fields both time and date display in each. I just want to display the time in the NEW_TIME field and date in the NEW_DATE field.
Here is my code:
'======================================
'create the NEW_TIME field
'======================================
strSQL = "ALTER TABLE " & tabName & " ADD NEW_TIME Date ShortTime"
DoCmd.RunSQL strSQL
MsgBox ("NEW_TIME field added to the table")
'======================================
'create the NEW_DATE field
'======================================
strSQL = "ALTER TABLE " & tabName & " ADD NEW_DATE Date ShortDate"
DoCmd.RunSQL strSQL
MsgBox ("NEW_DATE field added to the table")
'======================================
'change uploadtime from gmt to mst
'by subtracting 7 hrs
'======================================
strSQL = "UPDATE [TELLUS_TEMP_UPLOAD] " & _
"SET [TELLUS_TEMP_UPLOAD].NEW_TIME = ([UPLOAD_DATE]+[TELLUS_TEMP_UPLOAD]!UPLOAD_TIME)-CDate(#12/30/1899 7:0:0#)"
DoCmd.RunSQL strSQL
MsgBox ("Time Changed")
'======================================
'change date from gmt to mst
'by subtracting 7 hrs
'======================================
strSQL = "UPDATE [TELLUS_TEMP_UPLOAD] " & _
"SET [TELLUS_TEMP_UPLOAD].NEW_DATE = ([UPLOAD_DATE]+[TELLUS_TEMP_UPLOAD]!UPLOAD_TIME)-CDate(#12/30/1899 7:0:0#)"
DoCmd.RunSQL strSQL
MsgBox ("Date Changed")
thanks for your help!