Hi all,
I am facing a problem. I create a application that is insert date and time in SQL Server 2005 table from web page then i fetch this datetime type field in vb.net application and adding some hours or minute into it then again update that field
but the problem is when i insert via web (my .aspx page) it save as different format then the other one same function i use in vb.net application will give me different format in sql server
i use these-
.net version 2.0
my system windows XP regional setting has date format as dd/MMM/yyyy time format as h:mm:ss tt
sqlserver 2005 table with datetime field
in my aspx pages i use-
<font style="color:#0 09900">dim newdt1 as datetime<br>
newdt1 = Microsoft.Visua lBasic.FormatDa teTime(newdt, DateFormat.Gene ralDate)</font>
This is inserting date in sql server - 17.11.2008 15:23:54
after that i select this date in vb.net application project
<font style="color:#0 09900">dim newdttime as datetime<br>
' adding hr and min into current time<br>
newdttime = Date.Now.Add(Ne w TimeSpan(0, 10, 0))<br>
newdttime = Microsoft.Visua lBasic.FormatDa teTime(newdttim e, DateFormat.Gene ralDate)</font><br>
sql server save it as 17/Nov/2008 03:33:26 PM
<b style="color:#9 90000">My question is that same function is giving me different date format.</b> Why?
7 2680
Hi all,
I am facing a problem. I create a application that is insert date and time in SQL Server 2005 table from web page then i fetch this datetime type field in vb.net application and adding some hours or minute into it then again update that field
but the problem is when i insert via web (my .aspx page) it save as different format then the other one same function i use in vb.net application will give me different format in sql server
i use these-
.net version 2.0
my system windows XP regional setting has date format as dd/MMM/yyyy time format as h:mm:ss tt
sqlserver 2005 table with datetime field
in my aspx pages i use- - dim newdt1 as datetime
-
newdt1 = Microsoft.VisualBasic.FormatDateTime(newdt, DateFormat.GeneralDate)
This is inserting date in sql server - 17.11.2008 15:23:54
after that i select this date in vb.net application project - dim newdttime as datetime
-
' adding hr and min into current time
-
newdttime = Date.Now.Add(New TimeSpan(0, 10, 0))
-
-
newdttime = Microsoft.VisualBasic.FormatDateTime(newdttime, DateFormat.GeneralDate)
sql server save it as 17/Nov/2008 03:33:26 PM
[HTML]My question is that same function is giving me different date format. Why?[/HTML]
SQL server have a default mode of storing date-time field.
So when we retrive data ,it give us that default format value.
PRR 750
Recognized Expert Contributor
while saving datetime field you should specify the format, like ,to dd/mm/yy hh:mm etc... Again while retrieving records you should specfy the format ...The default format will be displayed if you dont specify... Datetime
SQL server have a default mode of storing date-time field.
So when we retrive data ,it give us that default format value.
thanks for your reply
but the problem seems not with sql server it stored whatever it vb code provide it to variable
at first time - i got sqlserver value in dd.mm.yyy h:mm:ss
an dwhen update i got sql server value is changed to dd/MMM/yyyy h:mm:ss tt (default format)
while saving datetime field you should specify the format, like ,to dd/mm/yy hh:mm etc... Again while retrieving records you should specfy the format ...The default format will be displayed if you dont specify... Datetime
but there is not any retrival of data here
i insert at first time that automatically takes different format(dd.MM.yy yy h:mm:ss)
when i update(overload same field) i got different format(dd/MMM/yyyy h:mm:ss tt) - default format
only change that i use same function Microsoft.Visua lBasic.FormatDa teTime(Date.Now , DateFormat.gene raldate)
but from different plateform [web(.aspx) and vb application(.vb )]
Plater 7,872
Recognized Expert Expert
DateTimes are not (assuming you are using DateTime objects and a DateTime columns) stored in any "format". They are stored as a number of seconds since their defined epoch start.
How the datetime is displayed is based on the format you give it.
also, try to use .NET conventions such as DateTime.toStri ng("mm/dd/yyyy HH:MM:ss"); instead of using the backwards Microsoft.Visua lBasic library.
DateFormat.Gene ralDate in combination might not produce the same value.
Try to format the date before save to the SQL Database Table. This could be a soluction for your issue.
Another way is before do anything with the data fetched on table, you can verify the format and change to the one expect.
I hope this help you
Rpicilli
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Donnal Walter |
last post by:
I was very surprised to discover that
>>> import datetime
>>> x = datetime.date(2004, 9, 14)
>>> y = datetime.datetime(2004, 9, 14, 6, 43, 15)
>>> print x == y
True
How can these two objects be considered equal? Is there a *general* way
to test for date != datetime as well as 4.5 != 4.6?
|
by: John Hunter |
last post by:
>>> from datetime import date
>>> dt = date(1005,1,1)
>>> print dt.strftime('%Y')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ValueError: year=1005 is before 1900; the datetime strftime() methods require year >= 1900
Does anyone know of a datetime string formatter that can handles
strftime format strings over the full range that datetime objects
support?
|
by: Fritz Switzer |
last post by:
I'd like to have a string assigned the value of a
DateTime.AddMinutes(amount) so that the string is formatted in "HH:MM"
format.
For example:
DateTime.Now.AddMinutes(30) returns "00:30"
DateTime.Now.AddMinutes(90) returns "1:30" or "01:30"
|
by: Frank Rizzo |
last post by:
Any ideas?
|
by: Ante Perkovic |
last post by:
Hi,
How to declare datetime object and set it to my birthday, first or
last day of this month or any other date.
I can't find any examples in VS.NET help!
BTW, what is the difference between date and datetime classes?
Please, help
| |
by: Alan Silver |
last post by:
Hello,
I have a custom control that displays the date and time. I currently
have properties for the day, month, year, hour and minute, which have to
be set separately. This is inefficient.
I would like to have one property that I can use to pass in a DateTime,
and have the control pull out the various bits from that. I tried ...
public DateTime DateTimeDT {
|
by: A.M |
last post by:
Hi,
I know we can assigne year, month and day to a DateTime value by the
constructor like
Dim dt As DateTime = New DateTime(2003,8,1)
How can i assign value by year, month and day? I am looking for a function
like this:
|
by: Reny J Joseph Thuthikattu |
last post by:
Hi,
I have a variabe in the format of 'DD-MON-YYYY HH:MI AM' .I want to add a
miniute to it.How can i do that?
by manipulation i want to make '01-JUNE-2004 11:59 PM' to '02-JUNE-2004
12:00 AM'
How do i do that?
Reny
---
|
by: Phil B |
last post by:
I am having a problem with a datetime from a web services provider
The provider is sending the following SOAP response
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tns="urn:JadeWebServices/WebServiceProvider/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
|
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: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
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: 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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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: 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: 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...
| |