In my database i have data with datetime type. I read this data from database and convert to string and stored in a string variable. I want to remove time part from the value. How i do this??
Remove String from a variable value.
Page 1 of 12 Replies - 685 Views - Last Post: 18 March 2013 - 06:33 AM
Replies To: Remove String from a variable value.
#2
Re: Remove String from a variable value.
Posted 18 March 2013 - 06:27 AM
In the SQL statement I believe you can do this (for MSSQL):
although I haven't tested it.
If you wish to do this after you have created the string version then advise us of the current format of this string; if it is of a fixed length then you might use Substring() to grab the part that you need.
CAST(YourField AS DATE)
although I haven't tested it.
If you wish to do this after you have created the string version then advise us of the current format of this string; if it is of a fixed length then you might use Substring() to grab the part that you need.
#3
Re: Remove String from a variable value.
Posted 18 March 2013 - 06:33 AM
You can also use the .ToString("MM/dd/yyyy") but you would have to cast to date first.
For example:
So if the value came from the database as 03/18/2013 09:32:00 AM
myDateOnlyString would be "03/18/2013"
For example:
myDateOnlyString = CDate(myReader("AccessDate")).ToString("MM/dd/yyyy")
So if the value came from the database as 03/18/2013 09:32:00 AM
myDateOnlyString would be "03/18/2013"
This post has been edited by CharlieMay: 18 March 2013 - 06:33 AM
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote





|