Convert String Date to Unix TimeStamp Sqlite3 [closed] - sql

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 2 years ago.
Improve this question
I've to copy a column in another column, but the result is that only the first row is copied and put in all the rows of the other column
I'm trying to execute this query:
UPDATE gdf_storico Set Data = (SELECT Giorno FROM timestamp)
But that stores the same date in all columns

In SQLite, you can use strftime() with modifier '%s' to convert a date to an epoch timestamp:
select datecol, strftime('%s', datecol) as unix_ts
from mytable

Related

Can you Help me to write optimize sql query? [closed]

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
My query too much time to execute for fetching data.
SELECT `app`.*, `pat`.`title`, `email_address`, `bad_debtor`, `county`, `date_of_birth`, `dentist_id`, `doctor_id`, `ethnicity`, `first_name`, `middle_name`, `last_name`, `gender`, `pat`.`mobile_phone`, `pat`.`prevent_appointment_booking`, `pat`.`use_email`, `pat`.`use_sms`, `pat`.`recall_method`, `pat`.`status`, `pat`.`pat_id`, `pat`.`active` FROM `patients` `pat` LEFT JOIN `appoiment` `app` ON `pat`.`id` = `app`.`patient_id` WHERE (date(app.start_time) > date(NOW()) - INTERVAL 7 DAY) and `app`.`state` IN ('Completed') and `app`.`patient_id` is not NULL GROUP BY `pat`.`id`
This part
WHERE (date(app.start_time) > date(NOW()) - INTERVAL 7 DAY) and `app`.`state` IN ('Completed') and `app`.`patient_id` is not NULL
the problem is in where clause which takes too much time.
help me to optimize query.
replace app. * with the correct column you need

Sql query to concatenate 2-3 columns one column is a number and another column is date datatypeusing Ms access [closed]

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 2 years ago.
Improve this question
Ex: if we concatenate 12345 and 31-dec-2019 If we concatenate using & symbol we get 1234531-dec-19 in Ms access but if we do same in excel we get 1234543830 so to get the result as we get in excel what is the query to get this.
You can use the CLng function to convert the date field to a number:
SELECT NumberField, DateField,
[NumberField] & CLng([DateField]) AS CombinedData
FROM Table4;

Get minimum time and max time for each day in sql query [closed]

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 2 years ago.
Improve this question
I have an data which includes Processeddate, start time and end time. I need to get minimum starttime and max endtime for each day.
Process date should be the first coulmn
Just use min() and max() function as shown below.
;WITH cte
AS (
SELECT Cast(processedDate AS DATE) AS processedDate
,min(startTime) minStartTime
,max(endTime) maxEndTime
FROM mytable
GROUP BY Cast(processedDate AS DATE)
)
SELECT *
FROM cte
WHERE month(processedDate) = 1
AND year(processedDate) = 2020
ORDER BY processedDate
db<>fiddle

How to format money value in SQL [closed]

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
Where is the problem with my sql command?
select REPLACE(CONVERT(varchar, CAST(price AS money), 1),'.','.') as price
output :
price
-----
145,000,00
I want output like this
price
-----
145.000,00
Formatting results is usually best left for the front end.
Having said that, with SQL Server 2016, use the format function with an appropriate locale:
declare #m money = 145000
select format (#m, '#,###.00', 'DE-de')

update sql query in new column [closed]

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 7 years ago.
Improve this question
I have a column in which i have 'goswara no. 21/1980' i need only 21 and year from date column like this col gr=21/year(date) through sql2005 query
http://sqlfiddle.com/#!6/bf991/6
something like this?
select
right(columnname,4) as year ,
SUBSTRING ( columnname ,len(columnname) - 6 ,2 ) as result
from test