473,398 Members | 2,393 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,398 software developers and data experts.

Date Literals That Include Milliseconds

I have a control uses the date and time, including milliseconds. I want to
be able to enter this information as an attribute in the *.aspx page.
Because all attributes are entered as strings in the *.aspx page, I need a
recognizable date/time string that includes the date and time, including
milliseconds. Can somebody tell me the best format to do this in? Thanks.
(NOTE: The date/time data is coming from a databound field from an SQL
Server database.)
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/
Aug 25 '07 #1
16 2294
Nathan,

Because there are so many processes bussy mostly, is the windows operating
system probably not that accurate that you can get the real time in
milliseconds.

However the datetime.millisecond gives something back what reaches that the
most, but that is not in a literal, so just appending the toString with the
& will probably be the best.

Cor

"Nathan Sokalski" <nj********@hotmail.comschreef in bericht
news:eY**************@TK2MSFTNGP05.phx.gbl...
>I have a control uses the date and time, including milliseconds. I want to
be able to enter this information as an attribute in the *.aspx page.
Because all attributes are entered as strings in the *.aspx page, I need a
recognizable date/time string that includes the date and time, including
milliseconds. Can somebody tell me the best format to do this in? Thanks.
(NOTE: The date/time data is coming from a databound field from an SQL
Server database.)
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/
Aug 26 '07 #2
"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:eY**************@TK2MSFTNGP05.phx.gbl...
>I have a control uses the date and time, including milliseconds. I want to
be able to enter this information as an attribute in the *.aspx page.
Because all attributes are entered as strings in the *.aspx page, I need a
recognizable date/time string that includes the date and time, including
milliseconds. Can somebody tell me the best format to do this in? Thanks.
(NOTE: The date/time data is coming from a databound field from an SQL
Server database.)
DateTime dtmDateTime = <however you get your datetime variable>;
string strDateTime = dtmDateTime.ToString("dd MMM yyyy HH:mm:ss:fff");
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 26 '07 #3
You have me confused; the examples you give are in the codebehind, I am
looking for a string that can be assigned to a datetime attribute that
includes milliseconds. For example:

<cc1:TimePicker id="timepkr" runat="server" SelectedTime="datetime string
with milliseconds">

SelectedTime is a property of type DateTime, so I need to know how to format
the string I assign to it. The examples you gave assign a String that you
didn't show me to a DateTime and assign a DateTime to a String. You did not
tell me the piece of information I am looking for: What format is the string
in when you assign it to the DateTime? Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:en*************@TK2MSFTNGP06.phx.gbl...
"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:eY**************@TK2MSFTNGP05.phx.gbl...
>>I have a control uses the date and time, including milliseconds. I want to
be able to enter this information as an attribute in the *.aspx page.
Because all attributes are entered as strings in the *.aspx page, I need a
recognizable date/time string that includes the date and time, including
milliseconds. Can somebody tell me the best format to do this in? Thanks.
(NOTE: The date/time data is coming from a databound field from an SQL
Server database.)

DateTime dtmDateTime = <however you get your datetime variable>;
string strDateTime = dtmDateTime.ToString("dd MMM yyyy HH:mm:ss:fff");
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 26 '07 #4
"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:e6**************@TK2MSFTNGP05.phx.gbl...
SelectedTime is a property of type DateTime
Er, no it isn't - the following MSDN page lists the properties of a DateTime
variable:
http://msdn2.microsoft.com/en-us/lib...es(VS.80).aspx

There is no SelectedTime property...

You said: "(NOTE: The date/time data is coming from a databound field from
an SQL Server database.)"

The code I gave you will accept a DateTime variable (which could be fetched
from a data object) and will then cast it to a string which includes
milliseconds...

If that's not what you require, then please explain in more detail...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 26 '07 #5
I'm sorry, I think I was unclear in the way I phrased that statement. When I
said "SelectedTime is a property of type DateTime", I meant that my Control
has a property named SelectedTime that is a DateTime, like the following:

Public Property SelectedTime() As DateTime

But back to my original question, are you saying that if I do something
like:

<cc1:TimePicker id="timepkr" runat="server" SelectedTime='<%#
DataBinder.Eval(Container.DataItem,"myfield") %>'>

It will assign the entire date & time including milliseconds from the
database to my SelectedTime property? The reason this concerned me is
because the single quotes around the databinding expression made me think
the value from the database was converted to a String before being assigned
to the property. Is this true, or will the exact value from the database be
assigned to the property without being converted to a string first? Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:e6**************@TK2MSFTNGP05.phx.gbl...
>SelectedTime is a property of type DateTime

Er, no it isn't - the following MSDN page lists the properties of a
DateTime variable:
http://msdn2.microsoft.com/en-us/lib...es(VS.80).aspx

There is no SelectedTime property...

You said: "(NOTE: The date/time data is coming from a databound field from
an SQL Server database.)"

The code I gave you will accept a DateTime variable (which could be
fetched from a data object) and will then cast it to a string which
includes milliseconds...

If that's not what you require, then please explain in more detail...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 27 '07 #6
"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:OH**************@TK2MSFTNGP02.phx.gbl...
I'm sorry, I think I was unclear in the way I phrased that statement. When
I said "SelectedTime is a property of type DateTime", I meant that my
Control has a property named SelectedTime that is a DateTime
I see...
But back to my original question, are you saying that if I do something
like:

<cc1:TimePicker id="timepkr" runat="server" SelectedTime='<%#
DataBinder.Eval(Container.DataItem,"myfield") %>'>

It will assign the entire date & time including milliseconds from the
database to my SelectedTime property? The reason this concerned me is
because the single quotes around the databinding expression made me think
the value from the database was converted to a String before being
assigned to the property. Is this true, or will the exact value from the
database be assigned to the property without being converted to a string
first?
What happened when you tried it...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 27 '07 #7
On Aug 25, 7:20 pm, "Nathan Sokalski" <njsokal...@hotmail.comwrote:
I have a control uses the date and time, including milliseconds. I want to
be able to enter this information as an attribute in the *.aspx page.
Because all attributes are entered as strings in the *.aspx page, I need a
recognizable date/time string that includes the date and time, including
milliseconds. Can somebody tell me the best format to do this in? Thanks.
(NOTE: The date/time data is coming from a databound field from an SQL
Server database.)
--
Nathan Sokalski
njsokal...@hotmail.comhttp://www.nathansokalski.com/
I believe you can use:

myDateTime.ToString("M/d/yyyy HH:mm:ss:fff")

To print a date something like:

8/27/2007 06:37:13:0257

Thanks,

Seth Rowe

Aug 27 '07 #8
"rowe_newsgroups" <ro********@yahoo.comwrote in message
news:11**********************@57g2000hsv.googlegro ups.com...
myDateTime.ToString("M/d/yyyy HH:mm:ss:fff")
See my first reply in this thread...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 27 '07 #9
On Aug 27, 6:40 am, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
"rowe_newsgroups" <rowe_em...@yahoo.comwrote in message

news:11**********************@57g2000hsv.googlegro ups.com...
myDateTime.ToString("M/d/yyyy HH:mm:ss:fff")

See my first reply in this thread...

--
Mark Rae
ASP.NET MVPhttp://www.markrae.net
Sorry Mark - didn't realize I repeated you. Apparently, this
originally multiposted thread turned into a crossposted thread. All
your earlier posts are only on the
microsoft.public.dotnet.framework.aspnet newsgroup and not the
microsoft.public.dotnet.languages.vb newsgroup from which I am
posting.

Thanks,

Seth Rowe

Aug 27 '07 #10
"rowe_newsgroups" <ro********@yahoo.comwrote in message
news:11**********************@22g2000hsm.googlegro ups.com...
Sorry Mark - didn't realize I repeated you. Apparently, this
originally multiposted thread turned into a crossposted thread. All
your earlier posts are only on the
microsoft.public.dotnet.framework.aspnet newsgroup and not the
microsoft.public.dotnet.languages.vb newsgroup from which I am
posting.
Ah right - the OP does have a habit of cross-posting, which I usually
correct if I remember...

X-posted deliberately to microsoft.public.dotnet.languages.vb
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 27 '07 #11
Did anybody read the Subject of this thread? It says Date LITERALS, not Date
Formatting. This means I want a Date String that already is a String that I
can assign to a Date Object. My reason for needing this is that I need to
declaratively assign a date to a Control Property in the *.aspx file using
Attributes. Any ideas? Thanks.

"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:eg**************@TK2MSFTNGP05.phx.gbl...
"rowe_newsgroups" <ro********@yahoo.comwrote in message
news:11**********************@57g2000hsv.googlegro ups.com...
> myDateTime.ToString("M/d/yyyy HH:mm:ss:fff")

See my first reply in this thread...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Aug 29 '07 #12
"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...

(Cross-posting and top-posting corrected)
Did anybody read the Subject of this thread?
Ahem...
It says Date LITERALS, not Date Formatting. This means I want a Date
String that already is a String that I can assign to a Date Object. My
reason for needing this is that I need to declaratively assign a date to a
Control Property in the *.aspx file using Attributes. Any ideas? Thanks.
string strDateLiteral = "29 Aug 2007 15:59:13:123";
DateTime dtmDate = DateTime.ParseExact(strDateLiteral, "dd MMM yyyy
HH:mm:ss:fff");

http://msdn2.microsoft.com/en-us/lib...ct(vs.80).aspx
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 29 '07 #13
Did anybody read the Subject of this thread? It says Date LITERALS, not Date
Formatting.
Seth's first rule of newsgroups: Act like an ***hole - receive no more
help.

With that said, I consider this a warning and try to help you again.
This means I want a Date String that already is a String that I
can assign to a Date Object.
I don't see the problem - you can assign the string for the Control's
property like this:

<uc1:DateUC ID="theDateUC" runat="server" TheDateTime='8/29/2007
09:01:52.257' />

In my usercontrol I created the property looks like:

public DateTime TheDateTime {
get {
return DateTime.Parse(this.dateTimeLiteral.Text);
}
set {
this.dateTimeLiteral.Text = value.ToString("M/d/yyyy
HH:mm:ss:fff");
}
}

And everything showed up in my literal control just fine.

Thanks,

Seth Rowe

Aug 29 '07 #14
"rowe_newsgroups" <ro********@yahoo.comwrote in message
news:11**********************@19g2000hsx.googlegro ups.com...
>Did anybody read the Subject of this thread? It says Date LITERALS, not
Date
Formatting.

Seth's first rule of newsgroups: Act like an ***hole - receive no more
help.
The OP is well-known for that - he's a recent graduate who firmly believes
that the world owes him a living, and that these newsgroups are his own
private helpdesk...

Maybe he'll grow up one day...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Aug 29 '07 #15
The OP is well-known for that - he's a recent graduate who firmly believes
that the world owes him a living, and that these newsgroups are his own
private helpdesk...

Maybe he'll grow up one day...
Thanks for the warning Mark, I'd go ahead and killfile him now if I
didn't insist on using google groups as my newsreader.

Thanks,

Seth Rowe

Aug 29 '07 #16
Nathan,

Maybe you can next time write a message like your subject, putting "Wood" in
your subject and start than to write about "Bush" does not give good
information.

This is what you wrote.
>>I need a recognizable date/time string that includes the date and time,
including
milliseconds.

This does not mean (probably beside in your mind)
>>a Date String that already is a String that I can assign to a Date Object.
Although it is for me completely not to understand what you want.

A DateTime literal is fixed in one format, which is based on the USA time
and almost never usable in the rest of the world or by internet sites which
are not only for the USA (In fact can that be all COM, ORG, NET, TV and more
of those sites). Therefore it probably even for most not recognisable what
you want in these very much international newsgroups.

Outside the USA probably nobody uses them.

Cor

"Nathan Sokalski" <nj********@hotmail.comschreef in bericht
news:%2****************@TK2MSFTNGP03.phx.gbl...
Did anybody read the Subject of this thread? It says Date LITERALS, not
Date Formatting. This means I want a Date String that already is a String
that I can assign to a Date Object. My reason for needing this is that I
need to declaratively assign a date to a Control Property in the *.aspx
file using Attributes. Any ideas? Thanks.

"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:eg**************@TK2MSFTNGP05.phx.gbl...
>"rowe_newsgroups" <ro********@yahoo.comwrote in message
news:11**********************@57g2000hsv.googlegr oups.com...
>> myDateTime.ToString("M/d/yyyy HH:mm:ss:fff")

See my first reply in this thread...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Aug 30 '07 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

26
by: sgershon | last post by:
Hi. I know this is should be a simple question. I know server-side web-programming, and never needed to use client-side scripting... until now :) I have done so far a little number of scripts...
6
by: Jim Davis | last post by:
Before I reinvent the wheel I thought I'd ask: anybody got a code snippet that will convert the common ISO8601 date formats to a JS date? By "common" I mean at the least ones described in this...
2
by: Kevin Thomas | last post by:
Hello, I have a date value in a table SQL Server database that looks like this: 2005-10-11 12:54:36.860 When I load the record into a dataset in VB.NET and retrieve the date value into code,...
17
by: | last post by:
Hello, I need to send a Java date (milliseconds since the epoch 1970-01-01 00:00:00.000 GMT) through a socket to a C++ app and reconstruct exactly the same date in the C++ app as in the Java...
26
by: jshanman | last post by:
I am writing a timeline that uses Google Maps. I have a function that converts a date time to latitude coords. This function is used to draw the markers on the timeline. I need a reverse function...
2
by: Rajat | last post by:
Hi, I have to draw a real time chart in which I have several entries at the same second (i.e. HH:MM:SS:Milleconds) The charting component only takes julian date for drawing the dates. I am...
6
by: rohayre | last post by:
Im a long time java developer and actually have never done anything with java scripting. I'd like to write a short simple script for calculating a date in the future based on today's date and a...
10
by: Nathan Sokalski | last post by:
I have a control uses the date and time, including milliseconds. I want to be able to enter this information as an attribute in the *.aspx page. Because all attributes are entered as strings in the...
0
yasirmturk
by: yasirmturk | last post by:
Standard Date and Time Functions The essential date and time functions that every SQL Server database should have to ensure that you can easily manipulate dates and times without the need for any...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
jinu1996
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...
0
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...
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.