I'm trying to save a date from a datetimepicker to SQL server database as duration of an user deactivation but i only want to save day month and year.
Here is my function so far:
Public Sub DeactivateUser(user As String, duration As Date)
Dim query As String
Dim startdate As Date = Date.Parse(Date.Now)
query = "Update SC_User Set Us_duration='" & duration & "','" & "Us_Start='" & startdate & "Where Us_User='" & user & "'"
query = "Update SC_User Set Us_Inactive" & 1 & "Where Us_User='" & user & "'"
If you want today's date without the current time then you use
Date.Today. If you want the date without the time from an arbitrary
DateTime value then you use its
Date property, e.g.
myDate = myDateTime.Date
Note that the
Date property still returns a
DateTime but with its time portion zeroed. Not surprisingly, the
Date.Today property is implemented like this:
If you want to store just a date without time in SQL Server then you should use the
date data type, which doesn't store time.