Sam
Sam

Reputation: 325

Set a variable to today's date (vb script / aspx)

I'm trying to set a variable to today's date using VB within an ASPX file. Does anyone know the correct syntax?

Upvotes: 0

Views: 2967

Answers (4)

Rahul Singh
Rahul Singh

Reputation: 21795

Try this:-

This will declare your date variable:-

<% Dim date As String = DateTime.Now.ToShortDateString() %>

This will print the value of variable date on response:-

<%= date %>

Upvotes: 1

Tushar Gupta
Tushar Gupta

Reputation: 15923

Try this as you wish to declare and assign the variable, you can use it further in your code

<% Dim a As String = DateTime.Now.ToShortDateString()%>

Upvotes: 1

Ekkehard.Horner
Ekkehard.Horner

Reputation: 38745

Use Date() or Now():

>> WScript.Echo Date()
>> WScript.Echo Now()
>>
23.04.2015
23.04.2015 12:15:46  ' <-- german locale

Upvotes: 1

Related Questions