maqskywalker
asked on
convert datetime to date
I'm using VB.NET in ASP Web Forms.
I have a button click like this:
Protected Sub Button1_Click(sender As Object, e As EventArgs)
Dim DateTimeVar1 As DateTime
DateTimeVar1 = "10/31/2018 01:05:00 PM"
'Set Label With Variable Value
Label1.Text = DateTimeVar1
End Sub
How do I convert the DateTime variable DateTimeVar1 to a Date variable called DateTimeVar2 ?
So then the value stored in DateTimeVar2 should be: 10/31/2018
I have a button click like this:
Protected Sub Button1_Click(sender As Object, e As EventArgs)
Dim DateTimeVar1 As DateTime
DateTimeVar1 = "10/31/2018 01:05:00 PM"
'Set Label With Variable Value
Label1.Text = DateTimeVar1
End Sub
How do I convert the DateTime variable DateTimeVar1 to a Date variable called DateTimeVar2 ?
So then the value stored in DateTimeVar2 should be: 10/31/2018
ASKER
Is there a way to remove the time part off the date variable.
See I need pass this date variable to a stored procedure parameter but the parameter needs to be fed only the date part like this: "10/31/2018"
Currently it's being fed "10/31/2018 12:49:00 PM"
See I need pass this date variable to a stored procedure parameter but the parameter needs to be fed only the date part like this: "10/31/2018"
Currently it's being fed "10/31/2018 12:49:00 PM"
Even if you stripped off the time component, if you pass it as a Date, you will actually be passing it as "10/31/2018 00:00:00 AM".
Can it be passed as a string?
Can it be passed as a string?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks worked great.
If you want to put it into a label, you should use:
Open in new window