Change char value to date
Change char value to date
(OP)
Hi
I have a line of code which I need to change to date, Could someone advise ASAP, I have tried to change as char top as Date but that does not work, Thanks
CAST(CONVERT (varchar(10), orderheader.DateTimeCreated, 103) AS char)
I have a line of code which I need to change to date, Could someone advise ASAP, I have tried to change as char top as Date but that does not work, Thanks
CAST(CONVERT (varchar(10), orderheader.DateTimeCreated, 103) AS char)
RE: Change char value to date
Otherwise try this
---- Andy
There is a great need for a sarcasm font.
RE: Change char value to date
I did this and got the date back, however I am trying to use msquery so I can select between 2 dates, but if I put in between [02/06/2020) AND [08/06/2020] I am getting dated from outside the range.
If I put in [02/06/2020) AND [06/06/2020] it brings back it correctly. I cant seem to choose between 2 different dates. I know msquery is not sql hence I thought it was the field not converted correctly.
CONVERT(varchar(10), orderheader.DateTimeCreated, 103) AS createddate
RE: Change char value to date
It wont let me select between 2 dates and result back correctly. I know this is not msquery forum , but I thought it could be the sql converting wrong?
RE: Change char value to date
---- Andy
There is a great need for a sarcasm font.
RE: Change char value to date
Yes I can , it is a very large statement though and is used in a bigger report, as you can see I am only interested in 2 subgroups. I am using msquery to get the results into excel for pivot use, but as I say the dates are not working on createdate field
CODE --> SQL
RE: Change char value to date
CODE
Try something like:
CODE
---- Andy
There is a great need for a sarcasm font.
RE: Change char value to date
Sorry the date I was just trying to get between 2 dates, attached is the code as it is now. I am using Msquery to draw this from a view and then into Excel using the createdate in msquery fto get between dates. As I said it works great if one date is input but then does not work if I put a range in. I can use the datetime field but then if I do 2 days it misses the second date out (exapled between 02/06/2020 and 03/06/2020), so I have to put in between 3 dates to get a result (02/06/2020 and 04/06/2020).
CODE --> sql
RE: Change char value to date
---- Andy
There is a great need for a sarcasm font.
RE: Change char value to date
In this case in order to get ALL of 03/06/2020 you need to do this ...
CODE
When you just specify EndDate you must remember that there is a TIME element and all you get is EndDate 00:00:00, but you miss 00:00:01 to 23:59:59. But is you specify < EndDate + 1, you get ALL od EndDate.
Skip,
Just traded in my OLD subtlety...
for a NUance!
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein