Hi i have a value entered into an asp text box,
procedureDateTx tBx.Text, thet has the format dd/MM/yyyy. I need to
convert this into a format recognisable by SQL server in order to
properly query the database.
I've tried a few DateTime.Parse methods but can't get any to work.
The format of these values in the database is
yyyy-MM-dd hh:mm:ss.000
Thanks 8 13032
Hi,
What are you doing? are you using a SP or a query?
These are the steps:
1- Make sure the text is correct ! , why not use a Calendar instead of a
Textbox?
2- Convert the text to DateTime :
DateTime.ParseE xact( textbox.Text, "dd/MM/yyyy" ,
DateTimeFormatI nfo.InvariantIn fo);
3- If you are using a sp, it's easy :
command.Paramet ers.Add("@assig neddate", SqlDbType.DateT ime).Value =
DateTime.ParseE xact( textbox.Text, "dd/MM/yyyy" ,
DateTimeFormatI nfo.InvariantIn fo);
4- If you are using a query then yo ushould use a parameterize query:
string selectSQL = "SELECT * FROM table1 WHERE tehdate= ? ";
SqlCommand selectCMD = new SqlCommand(sele ctSQL, theconn);
selectCMD.Param eters.Add("@the date", SqlDbType.NVarC har, 15).Value =
DateTime.ParseE xact( textbox.Text, "dd/MM/yyyy" ,
DateTimeFormatI nfo.InvariantIn fo);
cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Assimalyst " <c_******@hotma il.com> wrote in message
news:11******** *************@g 49g2000cwa.goog legroups.com... Hi i have a value entered into an asp text box, procedureDateTx tBx.Text, thet has the format dd/MM/yyyy. I need to convert this into a format recognisable by SQL server in order to properly query the database.
I've tried a few DateTime.Parse methods but can't get any to work.
The format of these values in the database is yyyy-MM-dd hh:mm:ss.000
Thanks
Hi,
What are you doing? are you using a SP or a query?
These are the steps:
1- Make sure the text is correct ! , why not use a Calendar instead of a
Textbox?
2- Convert the text to DateTime :
DateTime.ParseE xact( textbox.Text, "dd/MM/yyyy" ,
DateTimeFormatI nfo.InvariantIn fo);
3- If you are using a sp, it's easy :
command.Paramet ers.Add("@assig neddate", SqlDbType.DateT ime).Value =
DateTime.ParseE xact( textbox.Text, "dd/MM/yyyy" ,
DateTimeFormatI nfo.InvariantIn fo);
4- If you are using a query then yo ushould use a parameterize query:
string selectSQL = "SELECT * FROM table1 WHERE tehdate= ? ";
SqlCommand selectCMD = new SqlCommand(sele ctSQL, theconn);
selectCMD.Param eters.Add("@the date", SqlDbType.NVarC har, 15).Value =
DateTime.ParseE xact( textbox.Text, "dd/MM/yyyy" ,
DateTimeFormatI nfo.InvariantIn fo);
cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Assimalyst " <c_******@hotma il.com> wrote in message
news:11******** *************@g 49g2000cwa.goog legroups.com... Hi i have a value entered into an asp text box, procedureDateTx tBx.Text, thet has the format dd/MM/yyyy. I need to convert this into a format recognisable by SQL server in order to properly query the database.
I've tried a few DateTime.Parse methods but can't get any to work.
The format of these values in the database is yyyy-MM-dd hh:mm:ss.000
Thanks
Assimalyst wrote: Hi i have a value entered into an asp text box, procedureDateTx tBx.Text, thet has the format dd/MM/yyyy. I need to convert this into a format recognisable by SQL server in order to properly query the database.
I've tried a few DateTime.Parse methods but can't get any to work.
The format of these values in the database is yyyy-MM-dd hh:mm:ss.000
Thanks
To "properly" query the database, use a Command object and store the
date in the parameters, using the DateTime type, and letting the
database objects handle the transition from .NET to the database.
If you need to rewrite it so that it can be used in a string to query
the database, use DateTime.ToStri ng("format here") and specify the
correct format, "yyyy-MM-dd HH:mm:ss.000" would probably do the trick.
--
Lasse Vågsæther Karlsen http://www.vkarlsen.no/
mailto:la***@vk arlsen.no
PGP KeyID: 0x2A42A1C2
Assimalyst wrote: Hi i have a value entered into an asp text box, procedureDateTx tBx.Text, thet has the format dd/MM/yyyy. I need to convert this into a format recognisable by SQL server in order to properly query the database.
I've tried a few DateTime.Parse methods but can't get any to work.
The format of these values in the database is yyyy-MM-dd hh:mm:ss.000
Thanks
To "properly" query the database, use a Command object and store the
date in the parameters, using the DateTime type, and letting the
database objects handle the transition from .NET to the database.
If you need to rewrite it so that it can be used in a string to query
the database, use DateTime.ToStri ng("format here") and specify the
correct format, "yyyy-MM-dd HH:mm:ss.000" would probably do the trick.
--
Lasse Vågsæther Karlsen http://www.vkarlsen.no/
mailto:la***@vk arlsen.no
PGP KeyID: 0x2A42A1C2
"Assimalyst " <c_******@hotma il.com> wrote in message
news:11******** *************@g 49g2000cwa.goog legroups.com... Hi i have a value entered into an asp text box, procedureDateTx tBx.Text, thet has the format dd/MM/yyyy. I need to convert this into a format recognisable by SQL server in order to properly query the database.
I've tried a few DateTime.Parse methods but can't get any to work.
The format of these values in the database is yyyy-MM-dd hh:mm:ss.000
Thanks
Use DateTime.ParseE xact and pass it the exact format you are giving it.
--
Adam Clauss
"Assimalyst " <c_******@hotma il.com> wrote in message
news:11******** *************@g 49g2000cwa.goog legroups.com... Hi i have a value entered into an asp text box, procedureDateTx tBx.Text, thet has the format dd/MM/yyyy. I need to convert this into a format recognisable by SQL server in order to properly query the database.
I've tried a few DateTime.Parse methods but can't get any to work.
The format of these values in the database is yyyy-MM-dd hh:mm:ss.000
Thanks
Use DateTime.ParseE xact and pass it the exact format you are giving it.
--
Adam Clauss
"Assimalyst " <c_******@hotma il.com> wrote in message
news:11******** *************@g 49g2000cwa.goog legroups.com... Hi i have a value entered into an asp text box, procedureDateTx tBx.Text, thet has the format dd/MM/yyyy. I need to convert this into a format recognisable by SQL server in order to properly query the database.
I've tried a few DateTime.Parse methods but can't get any to work.
string SQL ="Select * from yourTable were yourDateColumn =
'"+this.procedu reDateTxtBx.ToS tring()
that is open for SQL injection but it will work. You could also have a SP
in the db where your :
exec yourProc procedureDateTx tBx.ToString()
"Assimalyst " <c_******@hotma il.com> wrote in message
news:11******** *************@g 49g2000cwa.goog legroups.com... Hi i have a value entered into an asp text box, procedureDateTx tBx.Text, thet has the format dd/MM/yyyy. I need to convert this into a format recognisable by SQL server in order to properly query the database.
I've tried a few DateTime.Parse methods but can't get any to work.
string SQL ="Select * from yourTable were yourDateColumn =
'"+this.procedu reDateTxtBx.ToS tring()
that is open for SQL injection but it will work. You could also have a SP
in the db where your :
exec yourProc procedureDateTx tBx.ToString() This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Richard Hollenbeck |
last post by:
I'm trying to write some code that will convert any of the most popular
standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan
1908) and compare the first with the second and calculate days, months, and
years. This is not for a college course. It's for my own personal
genealogy website. I'm stumped about the code. I'm working on it but not
making much progress. Is there any free code available anywhere? I know it...
|
by: Franck |
last post by:
Hi,
'm gettin mad about date conversion.
Here is the point.
Got and add-in for Excel which call functions from a web service (on a
remote server)
The remote server has regional settings set to "en-UK" and date to
|
by: Assimalyst |
last post by:
Hi i have a value entered into an asp text box,
procedureDateTxtBx.Text, thet has the format dd/MM/yyyy. I need to
convert this into a format recognisable by SQL server in order to
properly query the database.
I've tried a few DateTime.Parse methods but can't get any to work.
The format of these values in the database is
yyyy-MM-dd hh:mm:ss.000
|
by: abcabcabc |
last post by:
I write an application which can let user define own date format to input,
How to convert the date string to date value with end-user defined date
format?
Example, User Defined Date Format as "dd/MM/yyyy"
input as "01082003" convert to date value as, 01 Aug 2003
Example, User Defined Date Format as "yyyy,dd,MM"
|
by: bonnie.tangyn |
last post by:
Dear all
In my ASP page, user can enter date in dd/mm/yyyy format. How can I use
Javascript to convert dd/mm/yyyy to yyyy-mm-dd hh:mm:ss.
Please give me some advices.
Cheers
Bon
| |
by: kirke |
last post by:
Hi,
I have a datetime column named dtDateTime.
its format is "Oct 27 2006 12:00:00 "
I want to group by only date part of it and count
my code is
$sql1="SELECT convert(varchar,J1708Data.dtDateTime,120),
count(convert(varchar,J1708Data.dtDateTime,120))
|
by: RP |
last post by:
I am using SQL Server 2005 as backend. I have a Text Box that accepts
Date in the format dd-MM-yyyy. But when I attempt to insert a record,
an error is displayed: Cannot convert char to DateTime ....
Actually, when the text box has entry like 22-10-2005, it considers 22
as month whereas it is DD. How to convert the Text Box value to an
acceptable format.
I tried: DateTime.parse(txtDOB.Text,"dd-MM-yyyy")
|
by: Ashraf Ansari |
last post by:
Hi,
How Can I convert MM/dd/yyyy format into dd/MM/yyyy and the date
which is converted into dd/MM/yyyy should be in DateTime format. I do
not want to store it as a string.
Please help
Thanks in advance
|
by: Bobby Edward |
last post by:
In mysql the db stores date/time as this: yyyy-mm-dd
Is there an easy way to convert it to mm/dd/yyyy?
How about if it shows up in a datagrid column?
How about if the time is appended. For example, my sql is this format:
yyyy-mm-dd hh:ss:mm (no AM/PM)
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |