الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

التعامل مع الوقت في DB

مغلق
بدأه musaireae في 19 أكتوبر 2005 · 8 رد · 680 مشاهدة · في ASP.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

لدي مشكله مع التعامل مع الوقت في تخزينة في DB حيث انني اذا خزنتة لا يتخزن لوحده ففي هذاه الحالة لا استطيع التعامل معه و عمل مقارنات علية ارجو افادتي .

If you have an apple and I have an apple and we exchange these apples then you and I will still each have one apple. But if you have an idea and I have an idea and we exchange these ideas, then each of us will have two ideas.

#2

Musaireae;

i didnt understand what you mean about the Time

i recomend two methods in Dealing with the Time

1-join the date and the time like this:

asp classic: dim datetime=date&" "&time

asp.net: dim datetime as string = now.tostring

for the time only ... use the nvarchar data type for eveything .. and handle it by code in anyway you want it

Greso

#3

اخي الكريم...

الوقت لوحده لا يوجد له متغير و غالبا ما يكون متغير من نوع datetime

يمكنك ان تخزن الوقت لوحده و ذلك باستخراجه من متغير الوقت الحالي كالتالي:

select convert(char(10), getDate(), 108)
The return is: 13:15:10

و لذلك عند تخزين الوقت فقط ... يمكنك ان تقوم مثلا:

insert into YourTableName (FieldName) values (convert(char(10), getDate(), 108))

طبعا لو كان متغير FieldName من نوع datetime فإنه سيتم تخزينه التأريخ (وليس الوقت) كالتالي: 1900-01-01 إبتداءا من عام 1900 و ما اعتقد انه يفضل لك ان تفعل هكذا...

لذلك الافضل لك ان تخزن عنصر التأريخ على اساس الوقت الحالي عند عملية الادخال الى الـ DB و عند المقارنة بين التاريخ ... يمكنك استخدام الدالة السابقة:

convert(char(10), getdate(), 108)

اذا احببت ان تخزن التأريخ مع الملي ثانية ... استخدم

convert(char(10), getdate(), 14)

حاول ان تبحث اكثر عن دالة CONVERT

و السلام عليكم

تم تعديل هذه المشاركة بواسطة alharethi في 19 أكتوبر 2005 في 20:24

Quran_Signature.jpg
#4

يا اخي الكريم هل من الممكن توضيح كيفية استخدام الدالة التي في الاسفل مع عملية select اذا كانت القيمة مخزنة في DB على هيئة 04:21:45 2002/2/2 وانا اريد عمل التشييك على قيم الوقت فقط . مثال على ذلك انا اريد ارجاع فقط القيم المدخلة في الوقت المساوي للقيمة 04:21:45 كمثال على المطلوب .

convert(char(10), getdate(), 108)

If you have an apple and I have an apple and we exchange these apples then you and I will still each have one apple. But if you have an idea and I have an idea and we exchange these ideas, then each of us will have two ideas.

#5
select convert(char(10), date_add, 108) as timeadd from table

MCP

MCTS:.Net Framework 2.0: Web Applications

MCPD:Web Developer

#6

مشكور اخوي

If you have an apple and I have an apple and we exchange these apples then you and I will still each have one apple. But if you have an idea and I have an idea and we exchange these ideas, then each of us will have two ideas.

#7

انا بحثت عن دالة ترجع لي التاريخ فقط و وجدت

CONVERT(char(10),date_feild,3)

و لكن هذه الدالة ترجع لك التاريخ بالصيغة 99/01/01 و انا اريده ان يرجع بالصيغة 1999/01/01

If you have an apple and I have an apple and we exchange these apples then you and I will still each have one apple. But if you have an idea and I have an idea and we exchange these ideas, then each of us will have two ideas.

#8

CONVERT(char(10),date_feild,103)

Quran_Signature.jpg
#9

اشكر لك اهتمامك يا اخي

If you have an apple and I have an apple and we exchange these apples then you and I will still each have one apple. But if you have an idea and I have an idea and we exchange these ideas, then each of us will have two ideas.

هذا الموضوع مغلق.

مواضيع مشابهة