2

I'm accessing Paradox file by binary reading.

But I have a question. I don't know what conversion should I to do from Time in Paradox Database:

  • TimeSpan
  • DateTime
  • Or I should to convert to string
Ian
  • 33,605
  • 26
  • 118
  • 198
Alberto León
  • 2,879
  • 2
  • 25
  • 24

1 Answers1

2

The DateTime will always has the date part.

The TimeSpan is most likely what you need. It can keep the hours, minutes... without date.

EDIT: reaction to incorrect comment

Suggested mapping of the Time to DateTime is simply incorrect abstraction. Theny your C# property contains a date 01/01/0001 which is wrong (not intended) and also most be handled all the time you access such a property.

While TimeSpan, can show exactly what we want: the time ellpased from the middnight. So if we do map time from DB type, this will provide us with out of the box functionality: can be loaded as time, can be stored as a time.

Radim Köhler
  • 122,561
  • 47
  • 239
  • 335
  • Except that `TimeSpan` represents a *duration* rather than a specific time-of-day. Wrong abstraction. Database time values general map to `DateTime`, with the date set to 0001-01-01. – Nicholas Carey Nov 08 '12 at 10:00
  • It is not true. If you have SQL Server 2008 type Time, then you have to map it to TimeStamp. The DateTime in that case will contain default value, and this is not what we want. So as a mapping of SQL types time - C# has TimeStamp – Radim Köhler Nov 08 '12 at 10:02
  • @NicholasCarey The .NET framework team don't agree with you on your abstraction idea. DateTime contains the following property (which kinda directly contradicts you.): `public TimeSpan TimeOfDay { get; }` – Buh Buh Nov 08 '12 at 10:10
  • What you say, is because there could be more ellapsed time then 24 hours. But when the question is: how to map db `time` to C# - `TimeSpan` is the answer. – Radim Köhler Nov 08 '12 at 10:12
  • @Nicholas Carey I think specific time-of-day is allways the time elapsed from the start of the day, the 00:00 So I think, I should to accept this answer. – Alberto León Nov 08 '12 at 11:06
  • Just a clue from my experience: we had a table with two columns of DB type: `Date`, `Time`. It simply did not make sense to have C# property `DateTime`.Day, `DateTime`.Time. While `DateTime` and `TimeSpan` are doing the job, are readable and working out of the box to interrect appServer vs dbServer – Radim Köhler Nov 08 '12 at 11:13