473,406 Members | 2,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

date search in SQL

1
Hi all,
I need to search for a date field in 'MM-DD-YYYY' format..
any suggestions for this???
MY field is of datetime type...is this okay for the above format to search..
Jun 25 '07 #1
3 1551
Axlin
2
Hi.Your post is a little bit unclear.
Try this function to get your date time format

SELECT GETDATE();
GO

GETDATE() functions get today's date and time. execute the above statement in sql and you'll see the result.

You can type in 'Date' under Look For: in the Help>Index inside the SQL Server 2005 management studio and it will retrieve all the functions you need related to date time.

Gdluck!
Jun 25 '07 #2
Motoma
3,237 Expert 2GB
Hi all,
I need to search for a date field in 'MM-DD-YYYY' format..
any suggestions for this???
MY field is of datetime type...is this okay for the above format to search..
Use the substring, concatenation, and cast features of SQL to reorganize your date field to how SQLServer expects it.
Jun 25 '07 #3
Hi,

why this format? I think better is YYYY-MM-DD (but you can use own format)
try with example:

select * from XXX where convert(varchar(10), [Field], 120) = '2001-12-30'

when you want dateformat mm-dd-yyyy you should make some variations, like

select * from XXX where
right(convert(varchar(10), [Field], 120),2)+'-'+
left(right(convert(varchar(10), [Field], 120),5),2)+'-'+
left(convert(varchar(10), [Field], 120),4)
= '30-12-2001'




greatings
Zibi
Jul 4 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Greg | last post by:
I have a page that searches a database by a repairman's name and by a date range. It pulls info by the repairman's name but pulls all info in the database regardless of the date. Below is the code...
2
by: Alistair | last post by:
this is really bugging me as I can't see why this is happening. I have a page which runs as the reult of a search, records details of the search, it goes a bit like this. get dearch criteria...
5
by: justobservant | last post by:
When more than one keyword is typed into a search-query, most of the search-results displayed indicate specified keywords scattered throughout an entire website of content i.e., this is shown as...
4
by: keithsimpson3973 | last post by:
Please forgive me for being so stupid. I have searched this site and many others for what should be a simple thing. I have a vb 6 form with a textbox that I input a date into. I can't set the format...
17
by: Petyr David | last post by:
Just looking for the simplest. right now my perl script returns an error messge to the user if the date string is invalid. would like to do this before accessing the server. TX
7
by: Katherine | last post by:
I'm trying to filter the records on the mainform (MailingList) of my database using a field contained in a subform (Donations). I was basing my code off Allen Browne's Access Tips page (here:...
7
helpwithcode
by: helpwithcode | last post by:
Hi people, I am just learning java.I have been creating a project which involves JDBC Connectivity.I find that the statements, String string_dob=text_dob.getText(); //Converting string to...
0
by: mwalsh62 | last post by:
Greetings all! My first post here, and my mind is pudding at this point (any flavor you like)! I have been searching for days, and still can't figure out the proper syntax that I require. This...
0
by: =?Utf-8?B?QnJ5YW4=?= | last post by:
Hello group. I've migrated from Win 2003 server to Win 2008 server. I've been banging my head agaist a wall for several days now trying to figure this out. I have the following script that will...
0
by: =?Utf-8?B?QW5pdGhh?= | last post by:
Hi, Currently for Announcement library a custom column "publish start date" is added and under the search result webpart changed the xslt by filtering the result based on the publish start date...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.