473,320 Members | 1,845 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,320 software developers and data experts.

Date to long

Kit
hello

How to get a long value from date and vice versa .
Explanation with a code will be appreciated

Thank
Kit
Jul 21 '05 #1
10 1893
Hi Kit,

In J# code?

Cor
Jul 21 '05 #2
Hi Kit,

In J# code?

Cor
Jul 21 '05 #3
A little bit of extra explanation would be welcome.

1)How should the long look ? There are dozens of ways to represent a date by
a long : ddmmyyyy, mmddyyyy, ..., julian date, ... depending on what you
want to do with it (just representing, calculations, ...)
2)What language are you using ?

Somehow i get the distinct feeling that this might be homework.

Yves

"Kit" <an*******@discussions.microsoft.com> schreef in bericht
news:34**********************************@microsof t.com...
hello

How to get a long value from date and vice versa .
Explanation with a code will be appreciated.

Thanks
Kit

Jul 21 '05 #4
A little bit of extra explanation would be welcome.

1)How should the long look ? There are dozens of ways to represent a date by
a long : ddmmyyyy, mmddyyyy, ..., julian date, ... depending on what you
want to do with it (just representing, calculations, ...)
2)What language are you using ?

Somehow i get the distinct feeling that this might be homework.

Yves

"Kit" <an*******@discussions.microsoft.com> schreef in bericht
news:34**********************************@microsof t.com...
hello

How to get a long value from date and vice versa .
Explanation with a code will be appreciated.

Thanks
Kit

Jul 21 '05 #5
Kit
Thanks for ur reply

I'm using C# , i want date in all the possible formats(MM/DD/YYYY ....

Thanks in advance
Jul 21 '05 #6
Kit
Thanks for ur reply

I'm using C# , i want date in all the possible formats(MM/DD/YYYY ....

Thanks in advance
Jul 21 '05 #7
Kit <an*******@discussions.microsoft.com> wrote:
I'm using C# , i want date in all the possible formats(MM/DD/YYYY ....)


Look up "date and time format strings" in the MSDN index.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #8
Kit <an*******@discussions.microsoft.com> wrote:
I'm using C# , i want date in all the possible formats(MM/DD/YYYY ....)


Look up "date and time format strings" in the MSDN index.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #9
For the MM / DD / YY format :

public static long DateToLong(DateTime date) {
return date.Month * 1000000 + date.Day * 10000 + date.Year;
}
public static DateTime LongToDate(long date_as_long) {
return new DateTime((int) date_as_long % 10000, (int) date_as_long /
1000000, (int) (date_as_long / 10000) % 100);
}

Example :

Console.WriteLine("{0}", DateToLong(new DateTime(2004,4,28)));
Console.WriteLine("{0}", LongToDate(04282004).ToShortDateString());

The others will be very similar, you will only have to change the
calculations a bit depending on the position you want the different parts of
the date in the long.

Yves

"Kit" <an*******@discussions.microsoft.com> schreef in bericht
news:E0**********************************@microsof t.com...
Thanks for ur reply

I'm using C# , i want date in all the possible formats(MM/DD/YYYY ....)

Thanks in advance

Jul 21 '05 #10
For the MM / DD / YY format :

public static long DateToLong(DateTime date) {
return date.Month * 1000000 + date.Day * 10000 + date.Year;
}
public static DateTime LongToDate(long date_as_long) {
return new DateTime((int) date_as_long % 10000, (int) date_as_long /
1000000, (int) (date_as_long / 10000) % 100);
}

Example :

Console.WriteLine("{0}", DateToLong(new DateTime(2004,4,28)));
Console.WriteLine("{0}", LongToDate(04282004).ToShortDateString());

The others will be very similar, you will only have to change the
calculations a bit depending on the position you want the different parts of
the date in the long.

Yves

"Kit" <an*******@discussions.microsoft.com> schreef in bericht
news:E0**********************************@microsof t.com...
Thanks for ur reply

I'm using C# , i want date in all the possible formats(MM/DD/YYYY ....)

Thanks in advance

Jul 21 '05 #11

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

Similar topics

4
by: Chopper | last post by:
I realise this question has been raised many times but I am still no wiser as to why setting the locales will not work in my ASP application. I have searched on google groups etc. and tried...
1
by: Num | last post by:
Hi all, I have to convert a J2EE date as a long ("Millis") in a .NET date as a long ("Ticks") In Java, currentTimeMillis, is the difference, measured in milliseconds, between the current time...
0
by: UBI | last post by:
Vorrei suggerire una funzione completa per la differenza fra due date. (questo è codice freeware, niente di illegale) La funzione seguente permette il calcolo di una differenza precisa tra due...
1
by: Riley DeWiley | last post by:
I have an UPDATE query that is always setting 0 records. When I cut and paste the SQL into Access and use it, it fails in the same way unless I coerce the date fields to be '=now()', in which case...
5
by: Bryan Yeo | last post by:
Trying to get the user password expire date from AD, but there is no such field. What I could get is the PasswordLastChanged property. Is there anyway I could calculate the date or something? ...
2
by: - Steve - | last post by:
I'm taking the value of the expire date out of an AD account (accountExpires attribute) and passing it into this function. static DateTime LargeIntToDateTime(ActiveDs.LargeInteger li) { long...
3
by: yxq | last post by:
Hello, The XP Desktop clean wizard can get the last access time of desktop shortcut, i found that the info come from ...
5
by: Donkey | last post by:
Hello, I want to find out how many digits does each date type have and how many bytes does it occupy in memory, so I wrote a program below: #include <stdio.h> const long double...
1
by: JonathanParker | last post by:
Another quick one! Trying to search for records by both accounting period and by year in two seperate queries actioned by option buttons. I've sorted the formatting so it's in a UK format but I...
0
by: Wolfgrin | last post by:
Hi, I have set up a report In Access 2003 where there are 2 check boxes I refer to to change the color of the Date of that record. That part is working. I also need to Change the color of the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.