Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Начинающим";
Текущий архив: 2010.08.27;
Скачать: [xml.tar.bz2];

Вниз

Как отобразить миллесекунды в таблице БД   Найти похожие ветки 

 
Делфиец   (2010-03-16 20:05) [0]

Значит поле типа DateTime ADO Access при отображении даты и времени не отображает миллисекунды. Хотелось бы что бы отображались, но как заставить не знаю.
Самое главное, если да же и не возможно отобразить миллисекунды, то хочу узнать это поле, по крайней мере, умеет хранить их сохранять или нет.


 
Jeer ©   (2010-03-16 20:31) [1]

TDateTime на сегодняшнюю дату имеет разрешающую способность в микросекунды.


 
sniknik ©   (2010-03-16 20:57) [2]

> умеет хранить их сохранять или нет.
а что говорит справка в акцесс?


 
Anatoly Podgoretsky ©   (2010-03-16 21:02) [3]

> sniknik  (16.03.2010 20:57:02)  [2]

Справка JETSQL оперирует только годами.


 
sniknik ©   (2010-03-16 21:05) [4]

да не, там и время есть... до секунд. правда нужно именно в акцессе, видать не только из JETSQL данные берет.


 
sniknik ©   (2010-03-16 21:09) [5]

встать на формат поля типа  DateTime  и нажать F1

Format Property - Date/Time Data Type
See AlsoApplies ToExampleSpecificsYou can set the Format property to predefined date and time formats or use custom formats for the Date/Time data type.

Setting
Predefined Formats
The following table shows the predefined Format property settings for the Date/Time data type.

Setting Description
General Date (Default) If the value is a date only, no time is displayed; if the value is a time only, no date is displayed. This setting is a combination of the Short Date and Long Time settings.
Examples: 4/3/93, 05:34:00 PM, and 4/3/93 05:34:00 PM.

Long Date Same as the Long Date setting in the regional settings of Windows.
Example: Saturday, April 3, 1993.

Medium Date Example: 3-Apr-93.
Short Date Same as the Short Date setting in the regional settings of Windows.
Example: 4/3/93.

Warning  The Short Date setting assumes that dates between 1/1/00 and 12/31/29 are twenty-first century dates (that is, the years are assumed to be 2000 to 2029). Dates between 1/1/30 and 12/31/99 are assumed to be twentieth century dates (that is, the years are assumed to be 1930 to 1999).

Long Time Same as the setting on the Time tab in the regional settings of Windows.
Example: 5:34:23 PM.

Medium Time Example: 5:34 PM.
Short Time Example: 17:34.

Custom Formats
You can create custom date and time formats by using the following symbols.

Symbol Description
: (colon) Time separator. Separators are set in the regional settings of Windows.
/ Date separator.
c Same as the General Date predefined format.
d Day of the month in one or two numeric digits, as needed (1 to 31).
dd Day of the month in two numeric digits (01 to 31).
ddd First three letters of the weekday (Sun to Sat).
dddd Full name of the weekday (Sunday to Saturday).
ddddd Same as the Short Date predefined format.
dddddd Same as the Long Date predefined format.
w Day of the week (1 to 7).
ww Week of the year (1 to 53).
m Month of the year in one or two numeric digits, as needed (1 to 12).
mm Month of the year in two numeric digits (01 to 12).
mmm First three letters of the month (Jan to Dec).
mmmm Full name of the month (January to December).
q Date displayed as the quarter of the year (1 to 4).
y Number of the day of the year (1 to 366).
yy Last two digits of the year (01 to 99).
yyyy Full year (0100 to 9999).
h Hour in one or two digits, as needed (0 to 23).
hh Hour in two digits (00 to 23).
n Minute in one or two digits, as needed (0 to 59).
nn Minute in two digits (00 to 59).
s Second in one or two digits, as needed (0 to 59).
ss Second in two digits (00 to 59).
ttttt Same as the Long Time predefined format.
AM/PM Twelve-hour clock with the uppercase letters "AM" or "PM", as appropriate.
am/pm Twelve-hour clock with the lowercase letters "am" or "pm", as appropriate.
A/P Twelve-hour clock with the uppercase letter "A" or "P", as appropriate.
a/p Twelve-hour clock with the lowercase letter "a" or "p", as appropriate.
AMPM Twelve-hour clock with the appropriate morning/afternoon designator as defined in the regional settings of Windows.

Custom formats are displayed according to the settings specified in the regional settings of Windows. Custom formats inconsistent with the settings specified in the regional settings of Windows are ignored.

Note  If you want to add a comma or other separator to a custom format, enclose the separator in quotation marks as follows: mmm d", "yyyy.

Example
The following are examples of custom date/time formats.

Setting Display
ddd", "mmm d", "yyyy Mon, Jun 2, 1997
mmmm dd", "yyyy June 02, 1997
"This is week number "ww This is week number 22
"Today is "dddd Today is Tuesday

You could use a custom format to display "A.D." before or "B.C." after a year depending on whether a positive or negative number is entered. To see this custom format work, create a new table field, set its data type to Number, and enter a format as follows:

"A.D. " #;# " B.C."

Positive numbers are displayed as years with an "A.D." before the year. Negative numbers are displayed as years with a "B.C." after the year.


 
Делфиец   (2010-03-16 21:19) [6]

Думаю, что это зависит от того в каком формате хранится в БД, т.е. как БД хранит DateTime  во внутренем представлении, если как виде единого длинного числа, то наверно миллисекондсы наверно сохраняются, а если ввиде какого-нибудь форматированного структурированного представления, то всего скорей миллисекунды обрезаются. Вот возьму щас и проверю, сохраню в БД заданное время с миллисекондсами, а затем считаю и посмотрю восстановится ли время.


 
Anatoly Podgoretsky ©   (2010-03-16 21:22) [7]

> sniknik  (16.03.2010 21:05:04)  [4]

Я про справку, а не про работу.


 
Медвежонок Пятачок ©   (2010-03-16 21:24) [8]

разумеется.
в оракле тоже например есть тип дата_со_временем, который маппится в делфийский TDateTime

Причем то, что в делфийском TDateTime есть миллисекунды, еще не говорит о том, что в оракловом поле (в том про которое я говорю можно сохранить вреня с точностью до миллисекунд).

И там есть отдельный тип для этого.


 
Делфиец   (2010-03-16 22:04) [9]

ТDateTime однозначно хранит миллисекндсы ибо даже есть и проверка этого

var

 dt: TDataTime;
 stime: TSystemTime;
 st : String;
begin

 GetSystemTime(stime);    // возвращает полное системное время
                                    // c миллисекондцами в том чиcле
 dt := SystemTimeToDateTime(stime);
 st := FormatDateTime("HH:NN:SS.ZZZ",sdt); // возвращается время и миллисекондсы в том числе

end;


 
sniknik ©   (2010-03-16 22:10) [10]

а зачем проверки в дельфи, если изначально речь шла про аксесс (и все остальные говорят про него)?


 
Делфиец   (2010-03-16 22:26) [11]

Все разобрался посредством опытным путем

procedure TFrmMain.BitBtn1Click(Sender: TObject);
var
 sdt,sdt2: TDateTime;
 stt: TSystemTime;
begin
 FillChar(stt,SizeOf(stt),0);

 stt.wYear  := StrToInt("2010");
 stt.wMonth := StrToInt("03");
 stt.wDay   := StrToInt("15");
 stt.wHour  := StrToInt("8");
 stt.wMinute:= StrToInt("20");
 stt.wSecond:= StrToInt("32");
 stt.wMilliseconds:= StrToInt("578");

 sdt := SystemTimeToDateTime(stt);

 mminfo.Lines.Add("DateTime: "+DateTimeToStr(sdt));
 mminfo.Lines.Add("FormatDateTime: "+FormatDateTime("YYYY.MM.DD HH:NN:SS.ZZZ",sdt));

 ADOTable1.Edit;
 ADOTable1.Append;
 ADOTable1.FieldByName("EDateTime").Value:=sdt;
 ADOTable1.Post;

 ADOTable1.Close;
 ADOTable1.Open;

 ADOTable1.RecNo:=1;

 sdt2 := ADOTable1.FieldByName("EDateTime").AsDateTime;
 mminfo.Lines.Add("Full DataTime = "+FormatDateTime("YYYY.MM.DD HH:NN:SS.ZZZ",sdt2));

end;


Результат как и должен был быть:

DateTime: 15.03.2010 8:20:32
FormatDateTime: 2010.03.15 08:20:32.578
Full DataTime = 2010.03.15 08:20:32.578


 
Jeer ©   (2010-03-16 22:34) [12]

Давно не смотрел Access, похоже действительно формат ограничен, относительно дельфийского TDateTime.


 
Германн ©   (2010-03-17 01:19) [13]


> Делфиец   (16.03.10 22:26) [11]
>
> Все разобрался посредством опытным путем

Однако помни, что время, получаемое стандартными средствами Windows, дискретно. И дискрет этот ~15-16 мс.


 
Делфиец   (2010-03-17 08:10) [14]


> Германн ©   (17.03.10 01:19) [13]
> > Делфиец   (16.03.10 22:26) [11]> > Все разобрался посредством
> опытным путемОднако помни, что время, получаемое стандартными
> средствами Windows, дискретно. И дискрет этот ~15-16 мс.
>


Это уже не важно так как задача на точность не ставится. Задача в другом :
т.е. в БД нужно поритировать сообщения особытиях от сервера, а в качестве ключа попытытаться использовать полученное системное время, но вот проблема что отображаемое время в БД не отображает миллисекунды, а событий в одной секунде может быть записано несколько значит должны отображаться  миллисекунды. Даже пусть миллисекунды и неотображаются, но главное нужно выяснить будут ли они уникальными, если в ремя будет сохраняться с миллисекундами?


 
Anatoly Podgoretsky ©   (2010-03-17 09:05) [15]

> Делфиец  (17.03.2010 08:10:14)  [14]

Для ПК отображение не нужно, но можно ответить на твой вопрос сразу, уникальность не гарантирована и трудно достижима.


 
sniknik ©   (2010-03-17 09:17) [16]

т.е. это изобретение велосипеда, взамен простого использования давно известных автоинкремента+праймари кей... /гуида



Страницы: 1 вся ветка

Форум: "Начинающим";
Текущий архив: 2010.08.27;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.5 MB
Время: 0.086 c
2-1271443216
fiascko
2010-04-16 22:40
2010.08.27
invalid floating point operation


2-1269848151
bobby
2010-03-29 11:35
2010.08.27
Относительные пути Windows


2-1272565792
Bee
2010-04-29 22:29
2010.08.27
single and string


10-1167226388
Priest
2006-12-27 16:33
2010.08.27
Собственная реализация IDispatch


15-1264023028
Юрий
2010-01-21 00:30
2010.08.27
С днем рождения ! 21 января 2010 четверг





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский