Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date/Time Conversion 1

Status
Not open for further replies.

Swi

Programmer
Feb 4, 2002
1,965
US
Hi,

I have the following date format. I would like to split out the date (which would be easy enough but how would I translate the time to HH:MM AM/PM?

Ex. - 2023-07-06T14:34:21-04:00

I would like to have:

DateToUse = YYYY-MM-DD
TimeToUse = HH:MM AM/PM

Thanks.

Swi
 
This is using VBScript, which can easily be translated to VB6

Code:
arrDateTime = Split("2023-07-06T14:34:21-04:00","T")
WScript.Echo arrDateTime(0)
WScript.Echo arrDateTime(1)
arrTime = Split(arrDateTime(1),"-")
WScript.Echo arrTime(0)
WScript.Echo FormatDateTime(arrTime(0), vbShortTime)
WScript.Echo FormatDateTime(arrTime(0), vbLongTime)
returns

Code:
2023-07-06
14:34:21-04:00
14:34:21
14:34
2:34:21 PM

Joe

 
Thanks.

T14:34:21-04:00

I didn't know if I needed to do anything with the -04:00

Thanks again.

Swi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top