Question about Microsoft SQL Server 2005 Standard Edition
Can I do a SQL query to change the format of how the date (& time in a different field) is displayed before I pull it back into my VS 2010 .net reports? I just want a short date (& short time). Can someone provide an example? Thanks for any assistance.
The function you're probably looking for is CONVERT. Here's an example (101 applies the format "mm/dd/yyyy", 108 applies "hh:nn:ss"):
SELECT CONVERT(varchar(10),getdate(),101) as JustDate, CONVERT(varchar(8), getdate(), 108) as JustTime
(1 row(s) affected)
Posted on Sep 24, 2013
a 6ya expert can help you resolve that issue over the phone in a minute or two.
best thing about this new service is that you are never placed on hold and get to talk to real repairmen in the US.
the service is completely free and covers almost anything you can think of (from cars to computers, handyman, and even drones).
click here to download the app (for users in the US for now) and get all the help you need.
Posted on Jan 02, 2017
SOURCE: Help me..
It needs to be in the format "yyyy-dd-mm hh:mm:ss:nnn". The BETWEEN keyword must include the time as well. so if you want from DTPicker date of "2007-09-01" and "2007-09-10" it will literally be this "2007-09-01 00:00:00.000" and "2007-09-10 00:00:00.000" thus not including any of the day for the 10th. If you want the 10th, then you have increase Date2 + 1 day to be "2007-09-11 00:00:00.000".
You should always remember that dates include the time.
I like to use the >= date1 and < date2. It's a little more forgiving.
Posted on Nov 24, 2007
SOURCE: Microsoft Access Query
Your date form is what it wrong. In order to use dates in Access with a BETWEEN function clause the values have to specifically be dates.
You can create dates in literal strings using the # sign to bound them, as in:
Select DISTINCT [ActivityDate] between #1/1/08# and #12/31/08#
#....# tells Access to treat this literal string as a date.
If you are using non-literal values, such as a parameter handed into the query, which would then be a variable, you can't use #some_variable# to cause Access to view it as a Date since #...# is for literal values only. To convert (also called "casting" a variable), use the CDate function. CDate likes to know what format to expect the string to come in though so it helps to pass that along, as in:
Select DISTINCT [ActivityDate] between CDate(begin_dt_string) and CDate(end_dt_string)
Remember the date string you pass into CDate has to be readable as a date by CDate. So make sure you pass in something that it can handle (use the IsDate() function to check to be sure so you can avoid a runtime datatype casting error). If your locale is US, then passing in x/y/z it will take for MM/DD/YYYY. If Europe, it will take it as DD/MM/YYYY. So keep that in mind.
To convert out of a date, use the FORMAT() function. That is how you get a date data type value to become a string value.
More fun reading:
Hope this helps!
Posted on Feb 23, 2008
Tips for a great answer:
Mar 29, 2011 | Dymo DateMark Date/Time Stamper
Feb 17, 2011 | Dymo Date Mark Electronic Date/Time...
Oct 26, 2009 | Dymo DateMark Date/Time Stamper
May 27, 2009 | HP OfficeJet 6210 All-In-One InkJet...
Mar 06, 2009 | Microsoft Visual Basic 6.0 for PC
Feb 05, 2009 | Microsoft Computers & Internet
Nov 20, 2008 | Xerox WorkCentre Pro 575 Plain Paper Laser...
Nov 05, 2007 | Dymo DateMark Date/Time Stamper
Aug 23, 2007 | Microsoft SQL Server Standard Edition for...
90 people viewed this question
Usually answered in minutes!
Step 2: Please assign your manual to a product: