Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
In my database the date and time appear together with the data that was placed, but if I filter by date in C# as it has the time together I can't filter by date. Do I have to create a field for the date and another for the time?
...
WHERE med_date > '2021-06-08'
will get you all values that are after midnight at the start of today.
If you want to compute daily statistics then use CAST(... AS date) such as
SELECT CAST(med_date AS date) AS med_date, COUNT(*) AS n
FROM TheTable
GROUP BY CAST(med_date AS date)
ORDER BY 1
If you're using entity framework and LINQ to SQL queries, you can filter for date this way. Is that what you looking for?
dbcontext.DbSet<YouerEntity>.Where(x=>x.med_data.Date >= Date)
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 days ago.
Improve this question
the query is:
SELECT DISTINCT TOP 10 COUNT( pp.Id), cd.Country,cd.State, pp.Id,cd.Email,CAST(pp.CreateDate AS DATE) AS paymentdate FROM Payments pp
JOIN cdTbl cd
ON pp.Id = cd.Id
WHERE pp.CreateDate IS NOT NULL AND CAST(pp.CreateDate AS DATE) = CAST(GETDATE() AS DATE)
GROUP BY pp.Id, cd.Email,CAST(pp.CreateDate AS DATE),cd.Country,cd.State
HAVING COUNT( pp.Id) > 1 AND cd.Email IS NOT NULL
ORDER BY CAST(pp.CreateDate AS DATE) DESC
Thanks
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have a C# program that communicates with MySql database and I want to write current time to database column defined as TIME. Now, when I run my program the time that has been written is for example 00:00:19 and not for example 19:34:00. Why this happens and how can I solve this?
Thanks in advance
SOLUTION
This solved the problem:
DateTime.Now.ToString("yyyyMMddHHmmss")
this because the format mysql : "yyyy-MM-dd hh:mm:ss"
check the format in you programme or try to insert a String like this "2016-23-08 13:00:00"
I think the problem caused by dateTimeVariable.ToString() method of your DateTime value.
To solve this problem use dateTimeVariable.ToString("s") to convert the DateTime to standard DateTime string.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
My question is there any data type is there in MySQL to insert date of birth into the database table directly else which data type i can choose to insert date of birth into the table?
You're looking for a date, so use the data type DATE
Use the DATE datatype. See here: http://dev.mysql.com/doc/refman/5.1/en/datetime.html the DATE type is distinct from DATETIME in that it ignores the time. You must use the YYYY-MM-DD format in your INSERT OR UPDATE SQL if you're not using parameters (which you should be).
CREATE TABLE People (
dateOfBirth DATE NOT NULL
)
INSERT INTO People ( dateOfBirth ) VALUES ( '1966-07-01' )
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Sorry, for my question. Actually i am not able to clarify my question for my hurry up.
I have a table like below :
This table is LoginHistoryTable(When a user login my application, his history insert this table according to UserId). I get all data from table as a list.
Now i want to Know : How many times they logged in this month and the last month.
This is really simple but here you go. You need to compare month and year.
boo isCurrentMonth = DateTime.Now.Month == otherDate.Month
&& DateTime.Now.Year == otherDate.Year;
Something like..
public bool IsThisMonth(DateTime dt)
{
return dt.Month == DateTime.Now.Month;
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I want to run my Windows service at 9:00AM to 9:00PM and after the 9:00PM my all rows need to be saved to another table only one time and last day of month all records will be deleted and last day records will be saved..... please help me my Window service is running at 9:00AM to 9:00PM......
You can use a timer that fires every minute. And between 9:00 AM to 9:00 PM you set a flag to tell where to save the records.
The code that is executed could set:
if(DateTime.Now.Hour < 9 && DateTime.Now.Hour > 21)
TableToSaveTo = "secondTableToSaveTo";
else
TableToSaveTo = "primaryTableToSaveTo"
Then you use the value in TableToSave to when you do the actual saves