i'm making application using vb.net. i want to get current date from system. It'll be shown on aspx page then i want to insert it in database. how can i do that??
If you want the date on the server (not sure if you're asking for the date on the server or the date on the client) then you can use System.DateTime.Now to get the current date and time on the server expressed in local time. You can use System.Date.UtcNow to
get the current date and time on the server expressed in coordinated universal time.
If this post answered your question please remember to 'Mark as Answer'!
now i want to store it in database also. I'm using sql server 2000. i've set data type as date/time. can u tell me how to insert it through a vb function?? should i user "CURRENT_TIMESTAMP". if so; how can i use this in the setter function?
now i want to store it in database also. I'm using sql server 2000. i've set data type as date/time.
Here's three ways you can approach that:
1) Pass System.DataTime.Now to the SQL query or stored procedure
2) Use GETDATE() in a stored procedure
3) Set GETDATE() as the default value for the date/time column in SQL Server
bluebird07
Member
654 Points
174 Posts
how to get current system date?
Apr 17, 2006 08:46 PM|LINK
hi,
i'm making application using vb.net. i want to get current date from system. It'll be shown on aspx page then i want to insert it in database. how can i do that??
bpag
Contributor
3517 Points
533 Posts
Re: how to get current system date?
Apr 17, 2006 09:02 PM|LINK
Meson
Member
645 Points
127 Posts
Re: how to get current system date?
Apr 17, 2006 09:05 PM|LINK
bluebird07
Member
654 Points
174 Posts
Re: how to get current system date?
Apr 17, 2006 09:13 PM|LINK
StrongTypes
All-Star
30801 Points
6013 Posts
ASPInsiders
Re: how to get current system date?
Apr 17, 2006 09:16 PM|LINK
ASPX:
<asp:Label ID="CurrentTime" runat="server" />
Code-behind:
CurrentTime.Text = DateTime.Now.ToString()
HTH,
Ryan
bluebird07
Member
654 Points
174 Posts
Re: how to get current system date?
Apr 17, 2006 09:35 PM|LINK
StrongTypes
All-Star
30801 Points
6013 Posts
ASPInsiders
Re: how to get current system date?
Apr 17, 2006 09:39 PM|LINK
Here's three ways you can approach that:
1) Pass System.DataTime.Now to the SQL query or stored procedure
2) Use GETDATE() in a stored procedure
3) Set GETDATE() as the default value for the date/time column in SQL Server
HTH,
Ryan
bluebird07
Member
654 Points
174 Posts
Re: how to get current system date?
Apr 17, 2006 09:54 PM|LINK
is it feasible to write this function as; this is for business layer
Public Property currentDate() As String Get Return _CurrentDate End Get Set(ByVal Value As String)_CurrentDate = Value
End Set End Propertywhile for aspx.vb
CurrentDate.Text = DateTime.Now.ToString()
objCustomer.currentDate = txtDate.Text
ROGERBART
Member
4 Points
16 Posts
Re: how to get current system date?
Oct 16, 2008 01:01 AM|LINK
thanks for your post regarding the system date to string. Many hours wasted, now sorted thanks to you.
regards
marjan76
Member
4 Points
8 Posts
Re: how to get current system date?
Jan 29, 2009 12:13 PM|LINK
Hi there,
Thank you for the code. When I use this code in visual web developer 2008, it will display the date and the time in the following format:
Current Date/Time: 2009-01-28 05:09 .
How do I get it to display AM or PM as well? For instance 5:09 am
Thank you.