The date in my local machine is set to the dd/MM/yyyy format. When I
insert a date in a MS-Access DB table, it gets populated in the above
format. For e.g. if the date is, say, 8th March 2007, it gets
populated in the DB table as
08/03/2007
In other words, first the day is shown, then the month & finally the
year but when I retrieve it in ASP.NET & using DatePart, try to
extract the day & the month like this (assume that the date record
from the DB table is stored in a variable named dtOrderDate)
Response.Write( "Day: " & DatePart("d", dtOrderDate))
Response.Write( "Month: " & DatePart("m", dtOrderDate))
the first Response.Write outputs the day as 03 & the month as 08 where
as it should be the other way round i.e. the day should be 08 whereas
the month should be 03. The day & month values get reversed when I
just do Response.Write( dtOrderDate).
Can someone please point out what am I missing? 24 2035
On Mar 10, 5:03 pm, r...@rediffmail .com wrote:
The date in my local machine is set to the dd/MM/yyyy format. When I
insert a date in a MS-Access DB table, it gets populated in the above
format. For e.g. if the date is, say, 8th March 2007, it gets
populated in the DB table as
08/03/2007
In other words, first the day is shown, then the month & finally the
year but when I retrieve it in ASP.NET & using DatePart, try to
extract the day & the month like this (assume that the date record
from the DB table is stored in a variable named dtOrderDate)
Response.Write( "Day: " & DatePart("d", dtOrderDate))
Response.Write( "Month: " & DatePart("m", dtOrderDate))
the first Response.Write outputs the day as 03 & the month as 08 where
as it should be the other way round i.e. the day should be 08 whereas
the month should be 03. The day & month values get reversed when I
just do Response.Write( dtOrderDate).
Can someone please point out what am I missing?
I suppose, it means the date in the database is wrong? How do you
insert the date in the database (sql query format)? Try to insert
'2006-03-08' and see what happen...
"Alexey Smirnov" <al************ @gmail.comwrote in message
news:11******** **************@ v33g2000cwv.goo glegroups.com.. .
I suppose, it means the date in the database is wrong? How do you
insert the date in the database (sql query format)? Try to insert
'2006-03-08' and see what happen...
Or, even better, insert '08 Mar 2006' and you'll *never* have a problem
after that...
On Mar 10, 9:10 pm, "Alexey Smirnov" <alexey.smir... @gmail.comwrote :
On Mar 10, 5:03 pm, r...@rediffmail .com wrote:
The date in my local machine is set to the dd/MM/yyyy format. When I
insert a date in a MS-Access DB table, it gets populated in the above
format. For e.g. if the date is, say, 8th March 2007, it gets
populated in the DB table as
08/03/2007
In other words, first the day is shown, then the month & finally the
year but when I retrieve it in ASP.NET & using DatePart, try to
extract the day & the month like this (assume that the date record
from the DB table is stored in a variable named dtOrderDate)
Response.Write( "Day: " & DatePart("d", dtOrderDate))
Response.Write( "Month: " & DatePart("m", dtOrderDate))
the first Response.Write outputs the day as 03 & the month as 08 where
as it should be the other way round i.e. the day should be 08 whereas
the month should be 03. The day & month values get reversed when I
just do Response.Write( dtOrderDate).
Can someone please point out what am I missing?
I suppose, it means the date in the database is wrong? How do you
insert the date in the database (sql query format)? Try to insert
'2006-03-08' and see what happen...- Hide quoted text -
- Show quoted text -
Alexey, this is how I am inserting records in the Access DB table:
strSQL = "INSERT INTO CustomerDetails (CName, Mail, Address,
OrderDate) VALUES (?, ?, ?, ?)"
oledbCmd = New OleDbCommand(st rSQL, oledbConn)
With oledbCmd
.Parameters.Add WithValue("?", strName)
.Parameters.Add WithValue("?", strEMail)
.Parameters.Add WithValue("?", strAddress)
.Parameters.Add WithValue("?", DateTime.Now.To String)
End With
Note that I am casting the date (which is the last parameter) into
string. If I just use DateTime.Now (the data type of the column in the
DB table is Date/Time), then ASP.NET generates an error saying Data
type mismatch in criteria expression.
Any other ideas/suggestions?
On Mar 10, 5:18 pm, "Mark Rae" <m...@markNOSPA Mrae.comwrote:
"Alexey Smirnov" <alexey.smir... @gmail.comwrote in message
Or, even better, insert '08 Mar 2006' and you'll *never* have a problem
after that...
This format dependent on the system settings.
For example, with German locale it may not work (Mär).
"Alexey Smirnov" <al************ @gmail.comwrote in message
news:11******** **************@ j27g2000cwj.goo glegroups.com.. .
On Mar 10, 5:18 pm, "Mark Rae" <m...@markNOSPA Mrae.comwrote:
"Alexey Smirnov" <alexey.smir... @gmail.comwrote in message
Or, even better, insert '08 Mar 2006' and you'll *never* have a problem
after that...
This format dependent on the system settings.
For example, with German locale it may not work (Mär).
Indeed but, in Germany, it would be '08 Mär 2007'
The point is that the only truly unambiguous date format is four digit year
and three digit month...
Mark Rae wrote:
"Alexey Smirnov" <al************ @gmail.comwrote in message
news:11******** **************@ j27g2000cwj.goo glegroups.com.. .
On Mar 10, 5:18 pm, "Mark Rae" <m...@markNOSPA Mrae.comwrote:
>"Alexey Smirnov" <alexey.smir... @gmail.comwrote in message Or, even better, insert '08 Mar 2006' and you'll *never* have a problem after that...
This format dependent on the system settings.
For example, with German locale it may not work (Mär).
Indeed but, in Germany, it would be '08 Mär 2007'
The point is that the only truly unambiguous date format is four digit year
and three digit month...
The ISO 8601 format (yyyy-MM-dd) is also unambigous, and also it's
culture independent.
--
Göran Andersson
_____ http://www.guffa.com rn**@rediffmail .com wrote:
On Mar 10, 9:10 pm, "Alexey Smirnov" <alexey.smir... @gmail.comwrote :
>On Mar 10, 5:03 pm, r...@rediffmail .com wrote:
>>The date in my local machine is set to the dd/MM/yyyy format. When I insert a date in a MS-Access DB table, it gets populated in the above format. For e.g. if the date is, say, 8th March 2007, it gets populated in the DB table as 08/03/2007 In other words, first the day is shown, then the month & finally the year but when I retrieve it in ASP.NET & using DatePart, try to extract the day & the month like this (assume that the date record from the DB table is stored in a variable named dtOrderDate) Response.Writ e("Day: " & DatePart("d", dtOrderDate)) Response.Writ e("Month: " & DatePart("m", dtOrderDate)) the first Response.Write outputs the day as 03 & the month as 08 where as it should be the other way round i.e. the day should be 08 whereas the month should be 03. The day & month values get reversed when I just do Response.Write( dtOrderDate). Can someone please point out what am I missing?
I suppose, it means the date in the database is wrong? How do you insert the date in the database (sql query format)? Try to insert '2006-03-08' and see what happen...- Hide quoted text -
- Show quoted text -
Alexey, this is how I am inserting records in the Access DB table:
strSQL = "INSERT INTO CustomerDetails (CName, Mail, Address,
OrderDate) VALUES (?, ?, ?, ?)"
oledbCmd = New OleDbCommand(st rSQL, oledbConn)
With oledbCmd
.Parameters.Add WithValue("?", strName)
.Parameters.Add WithValue("?", strEMail)
.Parameters.Add WithValue("?", strAddress)
.Parameters.Add WithValue("?", DateTime.Now.To String)
End With
Note that I am casting the date (which is the last parameter) into
string. If I just use DateTime.Now (the data type of the column in the
DB table is Date/Time), then ASP.NET generates an error saying Data
type mismatch in criteria expression.
Any other ideas/suggestions?
As you are using parameters, there should be no problem with the date
format. The fact that you are converting the date to a string is causing
the problem.
You should specify the data type for the parameters:
..Parameters.Ad d("?", OleDbType.VarCh ar).Value = name
..Parameters.Ad d("?", OleDbType.VarCh ar).Value = email
..Parameters.Ad d("?", OleDbType.VarCh ar).Value = address
..Parameters.Ad d("?", OleDbType.Date) .Value = DateTime.Now
--
Göran Andersson
_____ http://www.guffa.com
"Göran Andersson" <gu***@guffa.co mwrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
>The point is that the only truly unambiguous date format is four digit year and three digit month...
The ISO 8601 format (yyyy-MM-dd) is also unambigous, and also it's culture
independent.
No it isn't...
What date is 2007-08-03?
Mark Rae wrote:
"Göran Andersson" <gu***@guffa.co mwrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
>>The point is that the only truly unambiguous date format is four digit year and three digit month...
The ISO 8601 format (yyyy-MM-dd) is also unambigous, and also it's culture independent.
No it isn't...
Yes, it is...
What date is 2007-08-03?
That is the third of august in the year 2007.
--
Göran Andersson
_____ http://www.guffa.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Symon R |
last post by:
This is a bit of a weird one that I haven't yet been able to solve - I'm
hoping someone out there can disprove my findings and tell me where I've
gone wrong!
I have designed a web service that accepts messages from .NET clients. The
web method call includes an object as one of it's parameters - this
reflected object has been given a property called "FutureDelivery" and
expects a DateTime value. The clients may be in different timezones...
|
by: Chris |
last post by:
Hello,
I'm having some problems right now with something that would seem to be
rather simple (and probably is). But, the solution is escaping me right
now.
Currently, I have created a data structure with a timestamp in it. This is
created in a DLL written in C++. The command that I use to get the
timestamp is:
|
by: Kevin |
last post by:
Hi All
I am having a problem retrieving a Date value from an
Access 2000 database using the OLEDbProvider. Can someone
tell me please how to create a DateTime Object with the
date fro m the Database, I need the database date to
subtract it from another date I have to gain the number
of days that have elapsed. I just cannot seem to get this
DateTime thing correct. The field in my Access Database
is defined as a short date. This is kind...
|
by: nobody |
last post by:
I know that given a FormatString and a DateTime you can use
DateTime.ToString(...) to convert the DateTime to a String. My question is
how can you turn that around? Given a String and a FormatString, how can
you convert the String back to a DateTime? DateTime.Parse(...) doesn't use
the FormatString.
Now admitedly, if the format string is just "MM", it can't be done. But if
the format string is "yyyyMMdd", or "ddMMMyyyy hhmmsst", it...
|
by: Cor Ligthert |
last post by:
Hello everybody,
Jay and Herfried are telling me every time when I use CDate that using the
datetime.parseexact is always the best way to do String to datetime
conversions. They don't tell why only that I have to listen to them because
they know it better.
They told also that in a business situation it is better to use
datetime.parseexact for changing cultures and not to use the globalization
setting. I did not give them this sample,...
| |
by: Ugur Ekinci |
last post by:
Hi ,
I have two Sql Server 2000 on seperate machines ,
First one accepts datetime format like ("dd.MM.yyyy hh:mm:ss")
And Second one accepts datetime format like ("MM.dd.yyyy hh:mm:ss")
1- Date formats are different because of SQL Collation?
2- Do regional Settings affect Sql date format?
3- (Important) When inserting a datetime into first server there is no
problem (15.12.2000 12:12:12) , but when I insert into second server (if...
|
by: H5N1 |
last post by:
Hi there
I know that a problem of different datetime strings formatting between
asp.net and ms sql has been covered here widely, but what I couldn't
find is the 100% safe way of getting datetime values from ms sql,
processing them in asp.net and getting them back into sql without any
risk with inconsistent Culture settings etc.
My question is: wouldn't keeping the datetime variables all the time in
datetime type, without any String...
|
by: iulian.ilea |
last post by:
Is correct to have a varchar field and insert dates of type dd/mm/yyyy
into it? I choose this method because I have an application that runs
on more than one server. So, if I used a datetime field (MSSQL Server)
it worked on my test machine. If I run the same application on another
machine with different regional settings is not working. I tried with
date_default_timezone_set to change timezone but is not changing. After...
|
by: Michel Posseth [MCP] |
last post by:
Hello we have encountered the following problems with the date time picker
control
A : datetime picker control gives focus to last entered field when moving
back and forward with focus how do we reset this to the first field ?
B : datetime picker in DD-MM-YYYY default format ( europe , NL-NL
localization ) refuses an entry of 31 on the DD filed cause the month is
already chosen to the current mont ( (02) februari wich only has 28...
|
by: Jeff |
last post by:
Hey
..NET 2.0
I'm about to create 2 input parameters for a method. These are 2 DateTime
parameters - one named "from" and another named "to"... - from and to
DateTime values...
Okay the trick is that the "from" DateTime should be like this
01.<MM>.<YYYY ss:mm.hh which means that today is the 03.12.2007 then the
|
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: 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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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: 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...
| |