-
Apr 6th, 2013, 07:51 AM
#1
Thread Starter
PowerPoster
new string what?
strNoWOCalDate = string(2-len(month(cdate(strCalDate))), "0") & month(cdate(strCalDate)) & string(2-len(day(cdate(strCalDate))), "0") & day(cdate(strCalDate)) & right(year(cdate(strCalDate)),2)
Does anyone know what the heck the above is doing?
I'm in the process of updating it to C# but that is classic ASP/VBScript code. I just dont quite get what its doing there.
-
Apr 6th, 2013, 08:39 AM
#2
Re: new string what?
It looks to me like it's taking a String representation of a date and reformatting it into MMddyy format. If you were to take a date string like "7/4/2013" (en-AU) and feed it to that code then I think that you'd get "040713" back. There's an easy way to test that, because that code should work the same way in VB.NET just as it would in VB6 or VBScript.
-
Apr 6th, 2013, 10:40 AM
#3
Thread Starter
PowerPoster
Re: new string what?
thanks.
yes indeed. I thought the code would work with VB.NET as well and compare it using that. just wanted to make sure I understood what was going on rather than comparing like for like.
-
Apr 8th, 2013, 10:12 AM
#4
Thread Starter
PowerPoster
Re: new string what?
unfortunately doing it in VB.NET does not quite work - compiler error:
Code:
Dim strCalDate As DateTime = Me.DateTimePicker1.Value
Dim strNoWOCalDate As String = string(2-len(month(cdate(strCalDate))), "0") & month(cdate(strCalDate)) & string(2-len(day(cdate(strCalDate))), "0") & day(cdate(strCalDate)) & right(year(cdate(strCalDate)),2)
error: '.' expected.
this is just before the opening bracket: = string(2-...
-
Apr 8th, 2013, 02:20 PM
#5
Re: new string what?
Does this give you the desired results?
Code:
Dim strCalDate As DateTime = Me.DateTimePicker1.Value
MessageBox.Show(strCalDate.ToString("MMddyy"))
-
Apr 8th, 2013, 02:30 PM
#6
Thread Starter
PowerPoster
Re: new string what?
indeed. I figured it out earlier and forgot to post!
so really, it is just MMddyy... wow... what a way to do it
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|