Jul 4, 2007 #1 lpb71 Technical User Joined Mar 10, 2004 Messages 57 Location GB How can I get a vb script to output the date and time into a ccyymmddhhmm format to a variable? Thanks
How can I get a vb script to output the date and time into a ccyymmddhhmm format to a variable? Thanks
Jul 4, 2007 #2 PHV MIS Joined Nov 8, 2002 Messages 53,708 Location FR I'd create this function: Code: Function myDateTime(dtVar) myDateTime = Year(dtVar) & Right("0" & Month(dtVar), 2) & Right("0" & Day(dtVar), 2) _ & Right("0" & Hour(dtVar), 2) & Right("0" & Minute(dtVar), 2) & Right("0" & Second(dtVar), 2) End Function and then: MsgBox myDateTime(Now) Hope This Helps, PH. FAQ219-2884 FAQ181-2886 Upvote 0 Downvote
I'd create this function: Code: Function myDateTime(dtVar) myDateTime = Year(dtVar) & Right("0" & Month(dtVar), 2) & Right("0" & Day(dtVar), 2) _ & Right("0" & Hour(dtVar), 2) & Right("0" & Minute(dtVar), 2) & Right("0" & Second(dtVar), 2) End Function and then: MsgBox myDateTime(Now) Hope This Helps, PH. FAQ219-2884 FAQ181-2886
Jul 4, 2007 Thread starter #3 lpb71 Technical User Joined Mar 10, 2004 Messages 57 Location GB Just what I needed. Many thanks Upvote 0 Downvote