
Rango de fechas actual a un dia anterior a la misma hora
Publicado por Christian César (2 intervenciones) el 17/04/2020 17:52:14
Buen dia
Tengo el siguiente query y lo que quiero es que muestre los registros generados desde el dia de ayer a las 3pm hasta los generados el dia de hoy a la misma hora con dia hora minuto y segundo
Me podrian apoyar con esto me parece que es usando la funcion GETDATE para la fecha actual pero nos e como poner desde el dia anterior hasta la fecha actual a las 3pm.
Tengo el siguiente query y lo que quiero es que muestre los registros generados desde el dia de ayer a las 3pm hasta los generados el dia de hoy a la misma hora con dia hora minuto y segundo
Me podrian apoyar con esto me parece que es usando la funcion GETDATE para la fecha actual pero nos e como poner desde el dia anterior hasta la fecha actual a las 3pm.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
SELECT
COALESCE(LTRIM(RTRIM(ISNULL(grp.last_name, ''))) + SPACE(20 - LEN(ISNULL(grp.last_name, ''))),'')+'|' AS 'Receptor',
COALESCE(LTRIM(RTRIM(ISNULL(orig.last_name, ''))) + SPACE(5 - LEN(ISNULL(orig.last_name, ''))),'')+'|' as 'Originator',
COALESCE(LTRIM(RTRIM(ISNULL(string1, ''))) + SPACE(8 - LEN(ISNULL(string1, ''))),'')+'|' as 'Action to Receptor',
COALESCE(ISNULL(CONVERT(VARCHAR(30), (DATEADD(second, a.open_date, '12/31/1969 8:00:00 PM'))),''),'')+'|' as 'Open Date',
COALESCE(a.ref_num,'')+'|' as 'Issue Number',
COALESCE(LTRIM(RTRIM(ISNULL(cat.sym, ''))) + SPACE(30 - LEN(ISNULL(cat.sym,''))),'')+'|' as 'Claim Reason',
COALESCE((CONVERT(VARCHAR(4000), ISNULL(a.description, '')) + SPACE(4000 - LEN(CONVERT(VARCHAR(4000), ISNULL(a.description, ''))))),'')+'|' as 'Issue Description',
COALESCE(LTRIM(RTRIM(ISNULL(a.string2, ''))) + SPACE(30 - LEN(ISNULL(a.string2, ''))),'|')+'|' as 'Card Number',
COALESCE(CONVERT(VARCHAR(30), ISNULL(convert(date, DATEADD(second, a.service_date, '12/31/1969 8:00:00 PM')), '')),'')+'|' as 'Transaction Date',
COALESCE(CONVERT(VARCHAR(16), ISNULL(convert(time, DATEADD(second, a.service_date, '12/31/1969 8:00:00 PM')), '')),'')+'|' as 'Transaction Time',
COALESCE(SPACE(25 - LEN(ISNULL(a.string3, ''))) + CONVERT(VARCHAR(25), ISNULL(a.string3, '')),'')+'|' as 'Claim Amount',
COALESCE(LTRIM(RTRIM(ISNULL(string4, ''))) + CONVERT(VARCHAR(25), ISNULL(string4, '')),'')+'|' as 'Terminal Number',
COALESCE(a.zmerchant_number,'')+'|' AS 'Merchant Number',
COALESCE(LTRIM(RTRIM(ISNULL(a.user1, ''))) + SPACE(25 - LEN(ISNULL(a.user1, ''))),'')+'|' AS 'Merchant Name',
COALESCE(LTRIM(RTRIM(ISNULL(string5, ''))) + SPACE(25 - LEN(ISNULL(string5, ''))),'')+'|' as 'Serial Number'
from issue a
LEFT JOIN ca_contact grp ON a.group_id = grp.contact_uuid
LEFT JOIN ca_contact orig ON a.requestor = orig.contact_uuid
LEFT JOIN issstat stat ON a.status = stat.code
LEFT JOIN isscat cat ON a.category = cat.code
WHERE
grp.last_name = 'BPPR (POS ACQUIRER)'";
Valora esta pregunta


0