S Sebastian Heyn Member Licensed User Longtime User Apr 30, 2014 #1 Hi, this doesnt seem to work Dim now As Long Dim df As String Dim date_string As String DateTime.DateFormat = "yyyyMMdd" DateTime.TimeFormat = "HHmmss" date_string=DateTime.Date(now) & "_" & DateTime.Time(now) Msgbox("The date is: " & date_string, "") if I do msgbox(datetime.date(now),"") etc it works. Where am I going wrong here?
Hi, this doesnt seem to work Dim now As Long Dim df As String Dim date_string As String DateTime.DateFormat = "yyyyMMdd" DateTime.TimeFormat = "HHmmss" date_string=DateTime.Date(now) & "_" & DateTime.Time(now) Msgbox("The date is: " & date_string, "") if I do msgbox(datetime.date(now),"") etc it works. Where am I going wrong here?
DonManfred Expert Licensed User Longtime User Apr 30, 2014 #2 I cannot see any errormessage. Maybe you missed it to post here? Maybe you did not explain what you expect and what you get. Code: Copy Dim df As String Dim date_string As String DateTime.DateFormat = "yyyyMMdd" DateTime.TimeFormat = "HHmmss" date_string=DateTime.Date(DateTime.Now) & "_" & DateTime.Time(DateTime.Now) Msgbox("The date is: " & date_string, "") Last edited: Apr 30, 2014 Upvote 0
I cannot see any errormessage. Maybe you missed it to post here? Maybe you did not explain what you expect and what you get. Code: Copy Dim df As String Dim date_string As String DateTime.DateFormat = "yyyyMMdd" DateTime.TimeFormat = "HHmmss" date_string=DateTime.Date(DateTime.Now) & "_" & DateTime.Time(DateTime.Now) Msgbox("The date is: " & date_string, "")
S Sebastian Heyn Member Licensed User Longtime User Apr 30, 2014 #3 Soorry. My mistake. when changing from the example code which was Msgbox("The date is: " & DateTime.Date(now) & CRLF & _"The time is: " & DateTime.Time(now), "") to using a string variable, I accidentally deleted the line now = DateTime.Now Then, the date was displayed: 19691231_190000 I am not really familiar with the syntax yet. and iam not happy with the documentation ( too view examples -compared to bascom- ) so I get annoyed and ask many questions. ) Upvote 0
Soorry. My mistake. when changing from the example code which was Msgbox("The date is: " & DateTime.Date(now) & CRLF & _"The time is: " & DateTime.Time(now), "") to using a string variable, I accidentally deleted the line now = DateTime.Now Then, the date was displayed: 19691231_190000 I am not really familiar with the syntax yet. and iam not happy with the documentation ( too view examples -compared to bascom- ) so I get annoyed and ask many questions. )
DonManfred Expert Licensed User Longtime User Apr 30, 2014 #4 If you feed the search-engine with the right keywords you´ll find a lot of good examples or good code-snippets Upvote 0
If you feed the search-engine with the right keywords you´ll find a lot of good examples or good code-snippets
eps Expert Licensed User Longtime User Apr 30, 2014 #5 What are you trying to end up with, I'm still not sure...? Is it? DDMMCCYY_HHMMSS? Upvote 0
eps Expert Licensed User Longtime User Apr 30, 2014 #6 You can probably do this is one go. As in : DateTime.Dateformat = "MM/dd/yyyy HH:mm:ss" and I think you can only really set this once. Maybe that is the issue you are getting. Upvote 0
You can probably do this is one go. As in : DateTime.Dateformat = "MM/dd/yyyy HH:mm:ss" and I think you can only really set this once. Maybe that is the issue you are getting.
DonManfred Expert Licensed User Longtime User Apr 30, 2014 #7 eps said: What are you trying to end up with, I'm still not sure...? Is it? DDMMCCYY_HHMMSS? Click to expand... Not really... Problem was that the DIMmed a long named now and wanted to use it in Code: Copy date_string=DateTime.Date(now) & "_" & DateTime.Time(now) and wondered why he get 19691231_190000 and not "today"... DIM now as long will not really work if you dont give a correct value to now.... Upvote 0
eps said: What are you trying to end up with, I'm still not sure...? Is it? DDMMCCYY_HHMMSS? Click to expand... Not really... Problem was that the DIMmed a long named now and wanted to use it in Code: Copy date_string=DateTime.Date(now) & "_" & DateTime.Time(now) and wondered why he get 19691231_190000 and not "today"... DIM now as long will not really work if you dont give a correct value to now....
DonManfred Expert Licensed User Longtime User Apr 30, 2014 #8 eps said: and I think you can only really set this once Click to expand... That´s wrong. You can use it as often you want. But be aware. the last one is active till you set a new Date- and/or Time-Format Code: Copy Dim date_string As String DateTime.DateFormat = "yyyyMMdd" DateTime.TimeFormat = "HHmmss" date_string=DateTime.Date(DateTime.Now) & "_" & DateTime.Time(DateTime.Now) Log(date_string) ' -> 20140430_222235 DateTime.DateFormat = "yyMMdd" DateTime.TimeFormat = "HHmm" date_string=DateTime.Date(DateTime.Now) & "_" & DateTime.Time(DateTime.Now) Log(date_string) ' -> 140430_2222 Upvote 0
eps said: and I think you can only really set this once Click to expand... That´s wrong. You can use it as often you want. But be aware. the last one is active till you set a new Date- and/or Time-Format Code: Copy Dim date_string As String DateTime.DateFormat = "yyyyMMdd" DateTime.TimeFormat = "HHmmss" date_string=DateTime.Date(DateTime.Now) & "_" & DateTime.Time(DateTime.Now) Log(date_string) ' -> 20140430_222235 DateTime.DateFormat = "yyMMdd" DateTime.TimeFormat = "HHmm" date_string=DateTime.Date(DateTime.Now) & "_" & DateTime.Time(DateTime.Now) Log(date_string) ' -> 140430_2222
S Sebastian Heyn Member Licensed User Longtime User Apr 30, 2014 #9 Exactly. If you dont give it a value its probably 0 or something Which really made me wonder, as I thought unix time is 1.1.1970, 0:0:0 -> But thats probably because the timezone is not right on my AVD. If anyone wonders, what iam trying to end up with: The timecode is used to name files. Like that the files are in an alphabetical (numeric) order. I personally dont like special characters in files, : is possible i think but / should not work with filenames.... Attachments mistake.png 26.8 KB · Views: 520 Upvote 0
Exactly. If you dont give it a value its probably 0 or something Which really made me wonder, as I thought unix time is 1.1.1970, 0:0:0 -> But thats probably because the timezone is not right on my AVD. If anyone wonders, what iam trying to end up with: The timecode is used to name files. Like that the files are in an alphabetical (numeric) order. I personally dont like special characters in files, : is possible i think but / should not work with filenames....
DonManfred Expert Licensed User Longtime User Apr 30, 2014 #10 Yes, / is not a good idea in filenames Upvote 0